4 ms·
> This is why I kind of hate the mantra of “if it’s used 2-3 times or more, wrap it in a function or class.” I think that’s a fine signal to use to identify th
by stouset 5y ago
> This is why I kind of hate the mantra of “if it’s used 2-3 times or more, wrap it in a function or class.”
I think that’s a fine signal to use to identify that something needs to be refactored, but that doesn’t absolve an engineer of having to think about how to actually do so.
It’s why I’ve always cringed at IDEs with “refactor selected code into its own function” actions. This is so rarely what you should ever be doing.
Refactoring is like butchering. You need to figure out how the muscles lie and separate them on their natural boundaries, not just start hacking things into parts because they seem too big. Once you’ve separated pieces across good functional boundaries you can start trimming and breaking things up to fit specific needs, but it has to start with stepping back and getting a wider view.