Humans get bored beyond line 10.
Problems
- Low Cohesion
- High coupling
- Difficult to read
Solutions
1) Refactor
2) Create small objects dealing with some of the tasks. Unit test them.
3) Compose methods
Examples
- Libraries
Sample Code
Wrong
Right
Detection
All linters can measure and warn when methods are larger than a predefined threshold.
Relations
Also Known as
- Long Method
More info
Tags
- Complexity
Credits
Photo by Hari Panicker on Unsplash
This article is part of the CodeSmell Series.
Discussion (2)
A developer I really respect said, "a developer can only hold one screen's worth of code at one time." And sets the function limit according to how big the average developer's screens are. I also like the way you said it, "humans get bored beyond line 10."
Sorry, but at first glance I didn't see any difference among the right and wrong code.