Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

How is the term 'refactoring' used?

by ggg (Scribe)
on Jun 04, 2004 at 05:30 UTC ( [id://360719]=perlquestion: print w/replies, xml ) Need Help??

ggg has asked for the wisdom of the Perl Monks concerning the following question:

I kept seeing monks talk about refactoring old code and in context it seemed thay were talking about rewriting old code. I wondered why the fancy word, so I did a search. It does mean rewriting code, but in tiny, very testable increments. OK, I sez to my self, that's a little fancier that just a rewrite.

Now I find myself wondering whether the term 'refactoring' has slipped into a more general usage meaning something less that the original meaning used by Stephen?

ggg

Replies are listed 'Best First'.
Re: How is the term 'refactoring' used?
by chromatic (Archbishop) on Jun 04, 2004 at 07:23 UTC

    Refactoring is like taking a complex mathematical equation and applying transformations to make it simpler.

    Rewriting is like taking a complex mathematical equation and trying to derive it again so that it's simpler.

    The latter may work, especially if you understand the problem really well, but there's no guarantee that it'll continue to work at every discrete step.

Re: How is the term 'refactoring' used?
by neniro (Priest) on Jun 04, 2004 at 05:59 UTC
    There was a very nice article about refactoring perl-code on perl.com last year.
Re: How is the term 'refactoring' used?
by dragonchild (Archbishop) on Jun 04, 2004 at 12:52 UTC
    Refactoring and rewriting are similar, in that they both change code that is unmaintainable. And, that's all they have in common.

    Rewriting is when you take the what a program does and write something from scratch to meet that specification. This requires a lot of work up front with no immediate result.

    Refactoring is when you take the how a program does and improve it. It is very possible that many refactorings can be proven logically equivalent without ever knowing what the program does. This is the important difference. One can safely refactor some code if one has a test-suite that only returns pass/fail and never know anything more. Rewriting requires more work.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

      Your explaination is very helpful. Thanks!

      ggg
Re: How is the term 'refactoring' used?
by pbeckingham (Parson) on Jun 04, 2004 at 13:29 UTC

    Refactoring and rewriting are very similar in effect - often refactoring involves rewriting. I believe the difference is in the intent and the scale: refactoring is the intent to improve code, from the smallest scale up - single statement, block or sub. Rewriting tends to be more of a "start again" approach to fixing something, and usually applied to a scale larger than a statement or block.

    I believe both terms can be used most of the time, but there are folks who strongly believe in XP who have a special meaning for the word refactoring, that implies more than the mere language definition.

Re: How is the term 'refactoring' used?
by CountZero (Bishop) on Jun 04, 2004 at 06:02 UTC
    Not that I have noticed. But then again as a non-native speaker of English, it may have totally escaped my attention. :-)

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-20 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found