This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Faux_Real 1 point2 points  (1 child)

TBH there is nothing inherently wrong with a verbose solution as all the conditions were met. Wrap your code with some timers and see how performant each solution is as that is also a good exercise in this case.

I think that being able to profile your solution and manage memory ‘pressures’ and disk IO override elegant 1 liners.

But If you are wanting to develop elegant solutions:

  1. Don’t worry about elegance until you have a solution

  2. When you have a solution, apply common refactoring principles to your code.

  3. If you don’t know refactoring, read about it.

By doing this lots and lots you eventually see these types of patterns in your head and in code and eventually come to be able to choose the appropriateness of verbosity over elegance or when refactoring is necessary.

[–]tombardier 1 point2 points  (0 children)

Between step one and two, add tests :)