3 ms·
> Extract your methods people, it's not that hard and it's a great habit to get into. It takes skill to get good at it but a decently named small function makes
by badpun 8y ago
> Extract your methods people, it's not that hard and it's a great habit to get into. It takes skill to get good at it but a decently named small function makes code more readable and more reliable.
For me it actually makes code less readable. It makes the system more complex (because you've added extra function definitions and function calls) and just jumping back-and-forth between those small function calls makes code harder to read. I would much prefer to have a larger method that just does things in order, and, for readability, have its body divided into sections, each in isolated brackets (so that variables have local scope) and commented if necessary.
- zawazzi 8y agoI think all humans are bounded by 7+/-2 chunks of working memory which I think correlates to upper bound of understandability. Personally I break up methods where I see more than 5-7 unique params/variables/concepts. Also usually co-locating related methods will help which is what OOP does.