Long methods
This is a very typical code smell, very sneaky, and often underestimated. Even though it may seem like a trivial topic to address, I’d like to share some thoughts.
Code is read much more than it’s written, so taking a little extra time to shorten a method can pay off big time. When you have to modify a long method, you have to read and comprehend every single line of code to make the change safely. In this case, we’re burdened with loading all the work this method does into our brains just to understand what’s happening, let alone have the ability to modify any part of it.
Long code is very likely doing more than one thing: according to the Single Responsibility Principle, a method should ideally focus on doing just one thing. It’s almost impossible to achieve that when you have so many lines of code.
It would be useful to know when “long” becomes “too long.” 10 lines? 20? 100? It’s hard to...