4 ms·
I think that if "First bit," "Second bit," etc can be called out that explicitly, I don't mind big functions that much. The trouble comes from functions where
by piinbinary 8y ago
I think that if "First bit," "Second bit," etc can be called out that explicitly, I don't mind big functions that much.
The trouble comes from functions where the various bits are all mixed together. This means that comments cannot easily name the sections (for me, one of the main advantages of a function is that it must be given a name), and you cannot easily narrow your reading to just the part you care about.
Another advantage of smaller functions is that some of them end up being general enough functionality to be worth sharing with other code.
Finally, it's possible to test doFirstBit() independently of the other logic in big().
- joshuamorton 8y agoOn the contrary, I have something like "a named section of a function should be refactored into a private helper" as a macros when doing code review. This explicitly to prevent the eventual evolution into a god function.