When did “rewrite” become “rewrite from scratch?!” In my 30 years of writing code, rewrite never meant rewriting from scratch — until the programming cults arrived on the scene at the beginning of the century, that is. Before them, “rewrite from scratch” meant — lo and behold — rewrite from scratch, and a plain “rewrite” meant what the cultists successfully have named “refactor.”

Similar Posts:

podcat said,

Wait, what? Since when did refactor mean rewrite from scratch? Its just “somehow” changing code for the better without breaking too much of the interface. You know, like breaking out common functionality from that 2000 line function, or just breaking it up into logical pieces so someone can understand it.

If some “agile guy” went and told you otherwise hes most probably wrong. I’ve had agile courses and practiced it quite a bit at work and there has never been any throwing away of huge parts of code for a rewrite.

Well, out comes Fowler with a book called refactoring, and then every monkey with a design patterns book has to start using the word everywhere to sound responsible. This way, they can Refactor to Patterns.

I happen to like the word “revise” myself, instead of rewrite. Most folks seem to not associate revise with “from scratch”.

Otherwise, “refactoring” is crap an IDE will do. Which is really useful about %0.00001 of the time. Usually when you’re staring at a mountain of poorly organized Java code, and you need to start by renaming everything.

Paul Sinnett said,

Andrew Lauritzen said,

I’ve personally not heard “refactoring” be used to contrast “rewriting from scratch”; rather I’m used to it meaning something more along the lines of “improve its readability, or simplify its structure, while preserving its existing functionality“, which is suitably different than the scope of “rewrite” to warrant a more specific term I think. As tristan mentions, “refactoring” is something that can be done purely at the semantic level of a program, and is honestly quite comparable to mathematical factoring (say transforming code in the form of ABABAB… to (AB)* or similar) that I think the term is fairly well-chosen.

Certainly ideally most refactoring work can be handled by a clever IDE, perhaps with some user direction. Perhaps more importantly, it can often be handled by more junior programmers as knowledge of the intricate details of the program operation typically isn’t required.

So while I do agree with you that it’s not a useful term as far as people use it to mean “rewrite not from scratch”, it does have a useful meaning if its definition is suitably restricted to “factoring” code (at the syntactic/semantic/smart IDE level) rather than changing it.

Mhh… I always associated the term “refactor” with a mechanical code transformation that does not change the behavior of the code.

Similar to factoring a polynomial (is that the word in english?).

Refactoring the code usually involves changing it through some IDE that can statically prove that the change it’s making won’t break the code. Note that it’s not very easy to do this for dinamically typed languages.