<?xml version="1.0" encoding="windows-1252"?>
<node id="180103" title="So I'm in a bit of a quandary" created="2002-07-08 03:01:57" updated="2005-07-27 17:31:35">
<type id="120">
perlmeditation</type>
<author id="119620">
vek</author>
<data>
<field name="doctext">
Fellow monks I seek your wisdom.&lt;br&gt;&lt;br&gt;
I'm going to be adding some new functionality to an existing program.  Unfortunately the code is &lt;b&gt;ugly&lt;/b&gt;.  No &lt;code&gt;-w&lt;/code&gt;, no &lt;code&gt;strict&lt;/code&gt;, global variables, highly inefficient and has red flags all over the place.  The distinct lack of consistancy within the code is particulary worrying.  Sometimes an array will be passed to a subroutine, sometimes a subroutine just goes to work on an array and you have &lt;b&gt;no&lt;/b&gt; idea who/what/why/where the array was created.  My first initial reaction was a rather loud "yuck" followed by a sigh.  On impulse and from a future maintenance perspective I would like to re-write it .&lt;br&gt;&lt;br&gt;
There are a number of factors that a weighing heavily on my mind as I ponder the re-write:&lt;br&gt;&lt;br&gt;

1.  The code is bad, but it's not broken.  I keep hearing "if it ain't broke don't fix it" at the back of my mind.  The program has been in production for a couple of years.&lt;br&gt;
2.  It's a large program and a re-write would take a decent amount of time.&lt;br&gt;&lt;br&gt;
And finally.&lt;br&gt;&lt;br&gt;
3.  My boss was the original author.  I'll obviously have to tread lightly so as to not offend.&lt;br&gt;&lt;br&gt;
Trying to find a nice way to explain the re-write is proving harder than I imagined.  I'm starting to wonder whether I should just leave alone and try to add the new functionality without changing the old code too much - but doing that will drive me nuts.&lt;br&gt;&lt;br&gt;

If you've ever come across similar circumstances how have you handled it?
&lt;br&gt;&lt;br&gt;
&lt;b&gt;Update:&lt;/b&gt;  I think big thankies are in order to all who offered their advice.  Nice one.
&lt;br&gt;&lt;br&gt;
Cheers.
&lt;br&gt;&lt;br&gt;
--
&lt;a href="http://vek.perlmonk.org"&gt;vek&lt;/a&gt;
--</field>
</data>
</node>
