Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://649277]
[james28909]: check if it is a hash or an array ect with ref in one sub.
[james28909]: like all the subs calling get_data get_array get_ect, you could just use get_data. once you send the data to get_data, check if it is a hash or an array ect. and do functions for each, in one sub
[james28909]: that looks like it would be alot more work than just renaming the sub though lol
[Lady_Aleena]: james28909, did you even look at the subs?
[james28909]: yes
[Lady_Aleena]: And you see how the first two are vastly different than the third, right?

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-05-24 04:58 GMT
Find Nodes?
    Voting Booth?