Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Refactoring

by chromatic (Archbishop)
on Apr 07, 2001 at 20:21 UTC ( #70724=note: print w/replies, xml ) Need Help??

in reply to Refactoring

The most important part of this is testing. Test, test, test.

If you don't know what your code is supposed to do, if you can't verify that it does what it's supposed to do, you can't ever refactor it. That's a problem.

A normal programming language gives you different ways to solve the same problem. Perl gives you more. If you've done a reasonably good job of encapsulation, you can often tweak things to improve them.

You won't be free to do this until you have external verification that the code you modified has the same (good) effect that it did before.

Refactoring is good. Refactoring without testing is nearly impossible.

Update: Okay, okay. Confident refactoring without testing is difficult. Avoid it if you can.

Replies are listed 'Best First'.
Re: Re: Refactoring
by dws (Chancellor) on Apr 07, 2001 at 21:22 UTC
    Refactoring is good. Refactoring without testing is nearly impossible.

    That's a bit strong. While cleaning up or migrating legacy code, I've done a lot of refactoring without having a solid base of unit tests. It can be done, but it's tough on the psyche.

    I think a more accurate statement is:

    It is difficult to refactor with confidence without having a complete set of regressions tests that cover the code you're refactoring.
    In fact, having adopted the "write your tests first" dictum from eXtreme Programming, I'm finding it uncomfortable to do any development without having a set of regression tests at hand. An infectious notion, that.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-09-20 07:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found