Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Refactoring prototypes - what am I going to break

by halley (Prior)
on Oct 30, 2007 at 19:45 UTC ( [id://648091]=note: print w/replies, xml ) Need Help??


in reply to Refactoring prototypes - what am I going to break

The standard wisdom on prototypes is: Don't.

The standard wisdom on prototypes is: Don't use them unless you really know what they're doing.

For old Perl code written by peers, you can judge if they had a clue. Usually they didn't; usually they think it's like C prototypes. Review how the functions are getting called. Test each change. For well-established code written by Perl gods or regular CPAN-submitters, you can usually leave them alone, they're there for a reason.

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

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

Replies are listed 'Best First'.
Re^2: Refactoring prototypes - what am I going to break
by throop (Chaplain) on Oct 30, 2007 at 22:52 UTC
    > or old Perl code written by peers, you can judge if they had a clue.

    Yeah, well I judged that, and that's why I wanted to get rid of the prototypes.

    > If it's not broke, don't fix it.

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

      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 ]

        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-16 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found