Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

It depends.

Hateful as spaghetti code may be, there’s also the plain fact that it has worked in production for a while and has accumulated various bug fixes too. If you start over from scratch, you have to redo everything, including the parts which happen to be decent (which is the majority of the code even in most “bad” codebases), and you will likely run into half of the same bugs all over.

You are almost always better off refactoring the spaghetti code iteratively as you work on it. Instead of adding just one more hack to make something work and deferring the proper implementation for later, clean up that one corner of the code you’re directly working on, as far as is sanely possible, and add your change on top of that. The right way to do this, of course, is by writing tests for the part of the code you are about to clean up, so you can be confident that your cleanup doesn’t break anything. Over time, the codebase will slowly tend towards sanity, and as you go along you will progressively accumulate a test suite that will give you confidence to attack the code more aggressively in the more seriously broken parts.

Most of this work is quite mechanical.

Very few codebases are so hairy and disastrous that throwing away the good and known working parts they contain is justified.

Makeshifts last the longest.

In reply to Re: The worst thing... by Aristotle
in thread Spaghetti code... by davido

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (6)
    As of 2019-10-15 04:43 GMT
    Find Nodes?
      Voting Booth?