Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

KM (4)

  (email not shown publicly)
AOL IM: perlguy13 (Add Buddy, Send Message)

I wrote a book, maybe you will buy it. Writing CGI Applications with Perl []

Journal of KM (4)

Wednesday July 30, 2003
10:50 AM

Spaghetti code to Ziti

[ #13786 ]

I mentioned I am refactoring some code for a client. My first step was reformatting (perltidy and some by-hand stuff), and fixing up some minor code mistakes and consolidation along the way. I'll tell ya, formatting helps wonders. Spending the time to do proper indenting, make some things more consistent, and more visually pleasing can make speghetti look much more like ziti.

Now I can start breaking out some redundant code and making it modular. The guy(s) who originally wrote this were, er.. not the greatest with code design. Sort of half Matt Wright-esque and half "Hey, noone else will ever work on this". Of course, now I am maintaining it so I feel the need to better it for my own sanity and time.

There are thousands of lines of code in about a dozen scripts. No warnings, no stricture, not even using (except for sections I added) or ANY (that's right NONE) modules from CPAN (again, except for my sections) aside from DBI. Thank god they didn't reinvent DBI along with everything else!!

So, now I need to plan how to keep making the code better without completely rewriting it. As I went through the code I noticed some obvious things to consolidate... so I guess I'll start there and see where it goes. At the very least, I can now visually follow the code!

mmmmmmm.... ziti

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • One of my greatest professional pleasures is deleting code while retaining necessary behavior. Sometimes I worry someone will sit me down against a generative algorithm and ask me to refactor two similar, nasty subroutines and I'll be there the rest of my life....

    • I got great satisfaction taking 30 line blocks and condensing them to 5-10 lines. I didn't get to delete anything yet with replacing it.. the code is one of these "Um, where did this variable come from?? DO I NEED IT??" works of art.

      I'll likely turn on warnings and stricture and work through the errors which will appear. Joy.