More good quotes:
A culture where problems are fixed as they appear is one of the most fundamental traits of successful projects. – Abraham Marin-Perez
How many times do we come across a pile of … wrongness . and don’t fix it? (While this can refer to almost anything in your life I am going to restrict my discussion to projects and IT. Feel free to extrapolate to encompass your whole life.) Have you ever walked into a kitchen, wanting to bake something but found that nothing was in its spot and the entire kitchen was a mess? Yeah, neither have I but that’s because I’ve never really had a desire to bake. Except for these wonderful chocolate chip cookies that we got from a recipe on the Internet. Anyway, back to the story.
Let’s change the story. Have you ever gotten in your vehicle after a tall/short person has been using your car? The seat is in the wrong position, the side mirrors are looking at the wrong part of the road, the rearview mirror is looking at the back seat/roof and the radio is just too darn loud/soft? You fix these things before driving. You get comfortable.
It’s kind of the same way with code, you need to be comfortable with the code. How do you get comfortable? Things follow a pattern if there are multiple methods of doing something you change things up and do it one way. If things don’t make sense you fix it. You generally clean things up, you remove the electronic detritus that pollutes the code and makes it difficult to understand or modify.
Or at least, that is what you would like to do. Unfortunately, do to the “but it’s just going to take five minutes” message, you almost never have the opportunity to do that because it’s going to take time. And testing.
So the best thing to do? Fix it while it is being built. If you are changing functionA and there is a problem with functionA, then fix it. You’re in there anyway, clean up the mess so that it doesn’t have that bird poop all over it, get a broom and clean up the filth lying on the floor and get out the old Spic ‘n Span and clean things up. Don’t leave it lying around for someone else to clean up. (Didn’t your mother/father ever tell you to “clean up your own mess”?)
For those that like fancy titles, this is called “technical debt”, knowing that there things that need to get fixed … but you’re not going to fix it. The next person changing the code now has to find the code underneath the debt and fix it. It takes more time and it is more error prone and will likely add to the technical debt.
Doesn’t it make sense to clean up while you’re building the code? Or, if you are given dirty code to begin with, clean up the code before making changes?