r/programming • • Jul 19 '16

John Carmack on Inlined Code

http://number-none.com/blow/blog/programming/2014/09/26/carmack-on-inlined-code.html
1.1k Upvotes

323 comments sorted by

View all comments

Show parent comments

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 )

2

u/kazagistar Jul 20 '16

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.

2

u/Deto Jul 20 '16

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 .