3 ms·
> He advocates a maximum of 4-5 lines per function to ensure readable code Yeah, and you end up with myriad of functions which are used once and only once and
by anton_gogolev 12y ago
> He advocates a maximum of 4-5 lines per function to ensure readable code
Yeah, and you end up with myriad of functions which are used once and only once and it becomes impossible to actually find code which does something useful.
- nly 12y ago... and good luck naming all those functions.
- pjc50 12y agoSee sibling comment about domain-specific language; there's nothing wrong with long function names if your autocomplete is working. Codebase I'm working with has names like "auditNullRecipeCursorAtEndOfOrderLineAdditionsIfRequired" and "getUnselectedSiblingWithSametabIndexOrCreateRepeatedChildIfLessThanMax"
- im2w1l 12y agoIt's hard to notice typos in names that long. Can you immediately tell where the typo is in auditNullRecipeCursorAtStartOfOrderLineAdditionsIfRequired ?
- pjc50 12y agoI can't tell at all. Fortunately, as long as someone hasn't declared another function with the typoed name, either Intellisense or the compiler will tell me. I have a much harder time with "_tcscpy_s" and similar suites of functions where a single-letter typo is likely to be a different function with the same signature.
- im2w1l 12y agoI changed ...End... to ...Start..., which could be a plausible real world bug.
- prodigal_erik 12y agoI don't have a tool that relieves me of needing to read all those names, so not having to type them isn't that helpful. Domain-specific languages are productive; their parts combine in ways giving novel results. A list of a million verbs you can only ever use for one purpose is not a language in that sense.
- mrweasel 12y agoI've tried to apply this to my coding, maybe not 4-5 lines, but definitively keeping to short functions/methods. You're right that you end up with a myriad of functions, may of which you only use once, but I was surprised how often I actually been finding myself reusing something. I have much more code reuse than I originally figured. One thing that might be an issue, depending on your temper is that your code almost becomes a DSL. Programs are pretty much stringed together by this "myriad" of custom functions, that might not be useful outside this one program.