What one thinks will be a straightforward rewrite from the beginning
can change in focus and gain features before the rewrite is done.
Yes, I suspect this happens rather a lot.
I once inherited an "unmaintainable" build system written as a huge DOS .BAT script.
Well, it was unmaintainable to me, because I didn't know .BAT very well and,
frankly, didn't want to. My strong opinion, expressed in Unix shell versus Perl
is that you should not write non-trivial systems in .BAT (or Unix shell).
Luckily, it was only a few thousand lines long and I was able to "rewrite"
it in Perl fairly painlessly.
Because the original design and interface was so bad, I "improved" it as I went,
so my "rewrite" ended up a fair bit different to the original.
Naturally, I didn't write it as a monolithic script, but as a number of modules
along with a small script mainline.
Now you and BrowserUk
may claim I didn't rewrite it, I wrote a new build system.
Fair enough, but I prefer not to argue about that any more. :)
The important strategic question is:
should I have "rewritten" it in Perl or improved it by changing
the existing .BAT script?
From my (biased) point of view, the "rewrite" was a raging success because we
were able to extend this system many times over the years (often by adding
new modules) and I feel the cost of the rewrite was got back many times
over by improved robustness and performance, along with much easier maintenance
over a period of many years.
Of course, rewriting small systems is easy.
Suppose this system has now grown to 100,000+ lines of Perl and the
person who takes it over dislikes Perl, claims it is a tangled mess,
and decides it would be more "maintainable" to rewrite it in Ruby or Python.
Is that a wise decision?
Though I would normally argue against that,
others have been known to argue for it (BTW, as far as I'm aware, sanity prevailed and Bugzilla is still written in Perl).
Whether it makes sense to rewrite depends on many factors:
how large the system is; how ambitiously you want to extend it; how clean is its code; and how
skillful are the rewriters.
I make the last point because unfortunately I've seen a number of
over-confident programmers over the years complain loudly
about a crappy old system, boldy rewrite it ... then end up with
a crappier system than the original!
In my experience, the quality of the developers doing the rewrite
a creaky old legacy system written by first-rate developers is
likely to be better than a shiny new one rewritten by mediocre developers.
Joel Spolsky cautions when you rewrite:
"there is absolutely no reason to believe that you are going to do a better job".
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link or
or How to display code and escape characters
are good places to start.