Ad
  • Custom User Avatar

    And I thought I had some unorthodox solution

  • Custom User Avatar

    When operations are able to be chained like this, it's always tempting to reduce the line count of a solution, especially when the potential exists to reduce it to just a single line. When we do that, though, we sacrifice an opportunity to communicate to maintenance developers the significance of intermediate operations.

    Here, for example, the significance of the split('') operation is left undisclosed, which is to deduce the "digits" from the original number. Applying the "extract variable" refactor to describe that significance is important in production-quality code.

    (I realize "production quality" isn't always the intent of the solutions's author, but my statement is for the benefit of those who might otherwise mistake this solution's "best practice" rating as an indicator of perfection.)