Perl: the Markov chain saw | |
PerlMonks |
Re: Difficult code (Resolutions)by gsiems (Deacon) |
on Aug 22, 2003 at 17:29 UTC ( [id://285873]=note: print w/replies, xml ) | Need Help?? |
I used to do maintenance on a in-house system that had originally been developed by some consultants (I used to not like consultants as a result of that). Parts of it were reasonably well written and other parts were really, really ugly.
While there were a few cases where entire chunks of the app got ripped/replaced as they were too horribly broken to be fixed incrementally, my approach was mostly to fix *only* the piece that needed to changing (that piece, that whole piece, and mostly nothing but that piece). FWIW, I considered a piece to be a function, subroutine, and/or method. For that piece, 1. First I'd fix the indenting/whitespace. 2. Then I'd pick a variable, figure out a better name and rename it-- I tended to search/replace one by one and checked how the variable was being used as I went. It was amazing how much dead code there was in the form of declare $variable... set $variable... set $variable again... set $variable yet again... end of code piece-- value of $variable never used. 3. Repeated step 2 for all variables, removing dead sections and unused variables as they were found. 4. Ensured that the code still worked the same as before I started. 5. Refactored the piece if it made sense to do so. 6. Tested it again. 7. Made my change. 8. Tested it again. Using this approach, I never rewrote the whole thing application, just the pieces that needed changes whether those changes were for bug fixes or new/different functionality. Some observations that I made alng the way was that there tended to be a correlation between:
my 2 cents. The box said "Requires Windows 98 or better" so I installed Linux.
In Section
Meditations
|
|