Welcome to the Monastery | |
PerlMonks |
Re^4: Refactoring prototypes - what am I going to breakby sfink (Deacon) |
on Nov 06, 2007 at 17:27 UTC ( [id://649277]=note: print w/replies, xml ) | Need Help?? |
I've heard that said before. Do you have a reference to a good argument for that position (to only refactor when code needs change?) Because it doesn't make any sense to me.
Sure, if this is code that might never need to be fixed or added to, then it makes perfect sense -- why spend effort on something that's good enough? Except that the only such code I know of is dead code. Code that isn't being run anymore. Anything that is actually running invariably needs something done to it sooner or later. The reason why I say that position doesn't make sense is because when something requires change, it requires change for a reason, and reasons tend to have (rather short) deadlines associated with them. This is the exact situation where you can't afford to do any nontrivial refactoring. In fact, I recommend doing the exact opposite of what you said -- refactor when the code doesn't require change. Specifically, when you need to make a change, sure go ahead and refactor as you're making the change if you have the time. But you won't, so just make the damn change anyway, in as quick and dirty a way as your conscience will permit, but be sure to go back and clean it up later. Often, you'll be able to slip the cleanup in between the time the change works, and the time when it goes to QA or production or wherever. (So it turns out you did have time to refactor -- but how could you have known that in advance? Unless you're a heck of a lot better at time estimates than I am. And your deadlines are more stable.) You may not take a tire off unless it's flat, but you should still change the oil before the engine seizes up.
In Section
Seekers of Perl Wisdom
|
|