I'd follow the suggestions above and do a rewrite instead of patching up the broken program. But even if I were to patch it up, here's my approach (free, and thus, worth its price) :

  1. First, make a backup of all files that seem remotely interesting, and store that backup on a CD, on a directory of the same machine, and possibly in your personal workspace somewhere.
  2. Set up your modified version, be it the patch or the rewrite, in a different directory than the original file. Use symlinks for data files if necessary, or better, use copies.
  3. Test your program in parallel to the original - check that the output of your new program is identical to the output of the original. You will face interesting challenges if the original modifies the input data - then you might have to isolate/rewrite the input and output routines to create a copy of the input and output, praying that the original program still works (You did make the backups, right ?).
  4. In each development step, compare your output against the original output (Perl can do this for you). Thus, you will end up with a program that is not as broken as the original, but works the same.
  5. At some time, you will decide that the original produces wrong data. Ask another, non-technical, person who should know what they're doing, if your data seems more correct than the original data. If the modification is OK, adapt your test result routine to accomodate for the difference in output, and go on.

This strategy will keep you close to the original, whatever way you chose to implement the functionality of the original. But by forcing your input/output to be the same, you are also bounded by those design decisions and miss the chance to refactor the whole process. But as the whole process seems to be lost in the winds of time, first trying a local fix seems much more manageable.


In reply to Re: Best way to fix a broken but functional program? by Corion
in thread Best way to fix a broken but functional program? by idnopheq

Title:
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, details, 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, summary, 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.