Ad
  • Custom User Avatar

    Depends on who's reading. If I am used to grasping the 4th line as a whole, it makes sense to me to write it as a unit.

    There is always more than one possible solution.

  • Custom User Avatar

    I think in programing there are a lot of possible solutions and you can evaluate each of them looking at various aspects.
    This isn't about who has the "best" solution overall. This is about learning that there is always more than one possible solution.
    For me it is essential to always write maintainable code. If you are used to do that in any case, then you will always write maintainable code, especially when it is for production environments.
    Thus, I do not agree, that in terms of clean code the shorter version is better as clean code is a lot about maintainable code.

  • Custom User Avatar

    Better than my proposal, nice!

  • Custom User Avatar

    Well... nice question... in my opinion, in terms of code maintenance I prefer a few more code lines because is easier for me, but in terms of clean code, less lines are better. What is the better solution? I think that there isn't a better solution, it depends on the programmer.

  • Custom User Avatar

    This was not written for maximum maintainability.

    Reading less is easier than reading more though. :P

  • Custom User Avatar

    I agree that this is shorter in terms of line-count, but what about readablity and maintainablity? My personal experience is that more explicit code is easier to read and to understand (in terms of code-maintenance).

  • Custom User Avatar

    Wrong code. See fork.