Are 5-line methods a great idea?

By | May 4, 2023

I need to write up a rebuttal of 5 line code principle.

  • Not every function can be represented cleanly in 5 lines
  • Slicing up functionality arbitrarily into 5 line methods is unlikely to result in maintainable concepts.
  • Forth examples
  • Harder to maintain if you need to go through a large number of methods to understand what’s happening.

My experience has been that it is sometimes useful to extract a concept as a method when it makes sense by itself and can be named. If you can’t think of a good name that covers the concept, then you don’t have a coherent method.

Leave a Reply

Your email address will not be published. Required fields are marked *