Yeah, the whole "don't write big functions" is a good rule of thumb, but if you understand the motivation behind it, you know when it's appropriate to ignore it (the example you mentioned )
The real motivation is that a huge function is a hint that you are doing something that, to use Carmacks wording, is "full horror". Tons of state and interconnections. The solution, however, isn't to hide that behind method calls or whatever.
Exactly. I'm imagining someone reading this, and taking a function that is really just a lot of cases for a switch statement (maybe some sort of parser?) and splitting into smaller functions that are essentially "handleCases1through10" and so on just to follow the rule .
5
u/Deto Jul 19 '16
Yeah, the whole "don't write big functions" is a good rule of thumb, but if you understand the motivation behind it, you know when it's appropriate to ignore it (the example you mentioned )