by eecks · 10y ago · 0 comments
Isn't the former promoted as better programming? IoC, decoupling, Law of Demeter, testability etc
You can imagine a million ways those assumptions break down, as well as a million ways they seem to but should actually be stuck to. Knowing the difference is the tough part.
It took 4 times as long to produce the solution that was 4 times bigger and more complex than it needed to be. Maintaining that huge body of code forever is more than 4x the effort over time than a single small function. And that's how you get a 0.25x (or less) programmer.
The sweet spot has a nice tradeoff between extra-time spent, and ease of migrating to a full-blown complicated and extensible solution. For me, I generally write my code in that middle ground. Stubbing out parts of my solution and then coming back to fill it in. In that sense, having separate functions with clearly-defined input/outputs or portions of work, aides me in completing my solution.
Best practice doesn't mean "make as many classes as possible" although I would probably break up two-pages into a few different functions (large functions, even when they are good code, invite programmers who come later to add to them in a messy way).