A stack of refactorings

I'm not sure if this is a bad habit of mine or if other programmers do this too. Sometimes after having partially written a program I'll decide I need to make some change which touches most of the code. So I'll start at the top of the program and work my way down, making that change whereever I see it needed. Partway through doing this, however, I'll notice some other similarly impactful change I want to make. Rather than adding the second refactoring to my TODO list and continuing with the first, I'll go right back up to the top of the program and work my way down again, this time making changes whereever I see either of the refactorings. I reckon I've had about as many as 5 refactorings going on at once sometimes (depending on how you count them - sometimes an earlier refactoring might supercede a later one).

Keeping all these refactorings in my head at once isn't as big a problem as it might sound, since looking at the code will jog my memory about what they are once I come across a site that needs to be changed. And all this reading of the code uncovers lots of bugs.

The downside is that I end up reading (and therefore fixing) the code at the top of my program much more than the code further down.

Leave a Reply