Don’t lie; you’ve gotten through a prototype or a phase 1 iteration of a project, but as soon as you have to revisit the project to refactor some code you’d rather find something else to do or start something new. Stop it.
As unattractive as hacking out code for a few hours and throwing it away seems, working with creatives in an agency setting taught me a very important way to approach work: Creatives know that what they come up with the first time is rarely what will be used in the end. It is a tough state-of-mind find yourself in, but as developers who call themselves passionate and creative types, we need to embrace refactoring as a part of the web design process.
The States of Mind
You might have come across one or more of these thoughts when approached with the reality of refactoring code. I’ve also included what I’ve learned how to think about these as well.
“I just got it to work, why start over again?”
It makes you learn better. Nothing’s a better teacher than breaking something that you got to work (especially if you didn’t know how you got it to work in the first place) and then doing it again.
“I’ll just come back to this later.”
No you won’t. At least not for a hot minute. If you can make quick changes to code while your in the middle of something, do it then and there. If you HAVE TO HAVE TO move on to something else for time’s sake, the least you can do is put some sensible comments around your code and throw in some TODOs to point you back in the right direction.
“This plugin does everything I need.”
Does it? Or could you come up with a vanilla solution if you took the time to think it through using what you already know how to do? The best solutions sometimes take the least effort to execute.
“I don’t have to change everything, just this, this and this.”
Really? If you don’t want to make code soup and wind up with unmaintainable code that you and your teammates WILL have to revisit in the future, do things the right way. Plan for what you have to change, document what you have to do and implement responsibly.
Long Story Short
Procrastinating on refactoring is a hard thing to get over, and I don’t think it’s going away anytime soon, but more times than not it’s a rewarding experience. When you realize that what you came up with on the second, third, forth go-round is pretty decent, you’ll thank yourself for starting over in the first place.