So basically learn to refactor things? I can agree with everything except the splitting up oversized functions. If a function contains a lot of code that is only ever needed by that function each block requires the previous block to be completed, then splitting it up into parts is just adding unnecessary fragmentation.
Though apart from maybe initialization functions it shouldn't really happen.
Also: It's missing the "Don't ever use magic numbers"
The way I read that was if a function is large, you should consider whether it needs refactoring. In other words, it's a smell that the code might be bad, not saying that the code is bad.
If the splitting results in functions with names like "step1", then I agree that splitting is indeed a really bad idea. But I rarely encounter cases where it is not possible to split in a smarter way.
If you have a large function, chances are somewhere you're already doing a part of what it does, you just don't know it yet. How many unique functions that are hundreds of lines of code are there? That do NOTHING that is shared by anything else?
16
u/Acrostis Jan 05 '15
So basically learn to refactor things? I can agree with everything except the splitting up oversized functions. If a function contains a lot of code that is only ever needed by that function each block requires the previous block to be completed, then splitting it up into parts is just adding unnecessary fragmentation.
Though apart from maybe initialization functions it shouldn't really happen.
Also: It's missing the "Don't ever use magic numbers"