I think anyone who does anything with programming and/or systems administration can feel your pain. I've inherited tons of code from previous admins, varying shell/c/vb/vc++, etc and it's been a riot trying to figure out what's going on.
I believe they fall in several categories and for each one, I've figured out a method that keeps my sanity.
1: Unorganized Q&D - quick and dirty, we've all seen those. No comments, sloppy code, chaotic design, definitely needs being rewritten as soon as possible. Filed away for later perusal.
2: Organized Q&D - at least an attempt to have a cleaner code of the previous statement, some comments, however brief, spaced/indented code in most areas. Some sections might need work but overall, functional and not necessarily needing rewriting.
3: Organized code in development - development code/scripting that looks good but may have design structures that are different than yours and since understanding what every line does, a possible rewrite using existing code but substituting your function/variable names can be done. Also might rewrite just for brevity/improvement/efficiency/etc but not needed due to development. This is common of the "if it ain't broke, don't fix it" clause.
4: Unorganized Q&D in production - same as point 1, but in production and is desparately in need of an immediate rewrite, however on-the-fly that may be. Bug fix to keep going, but filed immediately for cleaner/improved code.
5: Semi-organized lengthy inherited code in production - hardest kind to maintain. Production states that it's been added on and maintained for the duration by several groups/people and is good in some areas and possibly horrid in others. Possible rewrites through CVS/SourceSafe/etc are worthy, but only if the entire thing is done, otherwise it's just bug-fix and move on.
IMHO, I try to rewrite everything that isn't well-documented. I learned rather quick that as long as I know the function of the script/code, I can probably rewrite it faster than trying to figure out what variable $xn2 does. That's the beauty of the call-sign of perl -
"There's always another way to do it". That applies to everything in code, production and development alike. And fortunately, my sanity's been able to be kept although there are times when I really want to scream 'WTF is this?' when looking at some obscure non-documented code buried in the archives of legacy programs.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.