Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Refactoring prototypes - what am I going to break

by sfink (Deacon)
on Nov 06, 2007 at 17:27 UTC ( #649277=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Refactoring prototypes - what am I going to break
in thread Refactoring prototypes - what am I going to break

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.


Comment on Re^4: Refactoring prototypes - what am I going to break
Re^5: Refactoring prototypes - what am I going to break
by dragonchild (Archbishop) on Nov 06, 2007 at 17:39 UTC
    Any time you change a piece of code, you need to have a solid business reason for doing so. Right now, at $work, we're doing a complete refactor of our code similar to what you're describing. But, we are taking less than 2 weeks to do so, are refactoring a spike into productionizable code, have a test suite with significant coverage, and we have a project already lined up that needs the refactor. Any of those items aren't true and not only do we not get permission, but I (as project manager) don't even try to get permission because I don't think it would be proper.

    In general, I agree that refactoring should be an ongoing process and that it should be built into the schedule. All schedules should have flex that can be returned back to the manager, but can also be used up in refactoring or other bugfixes. If you're scheduling to the bare metal, you're just asking for trouble.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://649277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-12-28 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (179 votes), past polls