Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by halley (Prior)
on Oct 31, 2007 at 13:09 UTC ( [id://648245]=note: print w/replies, xml ) Need Help??


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

Well, it works, but it's not very maintainable. Should it be refactored?

You refactor when the code requires change. When it requires change, you use that opportunity to make it better. You don't take the tire off unless it's flat, or you have to rotate them all.

--
[ e d @ h a l l e y . c c ]

  • Comment on Re^3: Refactoring prototypes - what am I going to break

Replies are listed 'Best First'.
Re^4: Refactoring prototypes - what am I going to break
by sfink (Deacon) on Nov 06, 2007 at 17:27 UTC
    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.

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://648245]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-25 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found