Writing better methods
Composing methods is a fundamental skill that should be a part of every developer’s refactoring toolkit. To put it simply, almost bluntly, it’s about breaking your code into smaller pieces, each of which does just one thing in a very readable way, in a very procedural manner; you could almost think of it as a recipe (please forgive me; I’m Italian, so I always bring everything back to food). The details are hidden in the methods beneath the composed method; this allows us to read our logic, our code, at a high level – I dare say, almost “in prose.”
When refactoring your code, the process typically involves extracting code from the original method. If you find it challenging to come up with meaningful names for the extracted methods, it’s a clear sign that the code chunk you were about to extract may be too extensive. Another case I’ve come across is when someone (sometimes myself) suggested naming a method...