|Syntactic Confectionery Delight|
ARRRGH! SPAGHETTI CODE FOR DINNER AGAIN!
I've seen more spaghetti code in my lifetime than I'd care to admit to. Mostly out of embarrasment for the authors who left it behind for me to find and in a couple of cases (I'll confess) out of embarrasment for finding some that I wrote years after I wrote it.
The obligatory anecdotes
One fellow, whose name will not be mentioned to protect a friend, whom I owe a great debt of gratitude for pushing me in the right direction when I was a newbie to the world of *nix and helped learn when I was starting in that brave new world, also bequeathed to me a project that he was working on that was a prime example of spaghetti code at its best.
He wrote this wonderful application that consisted of Pascal code that called shell scripts (!) that were strung together via pipes invoking a mix of C language programs and Fortran programs with some bc thrown in for good measure. Some munging of text was also done by awk in between and a wide assortment of temporary files littering the disc, some of which were never cleaned up after.
Did I mention I was a newbie at this point in my career?</p.
After he left the company that he and I worked at together, "Luke", our boss at the time (well, mine now, not his) walked into my cubicle and announced to me that I now had to work on the project my mentor left behind.
From those humble beginnings I went from barely being able to compile a "hello world" C program on Unix (HPUX 1.0 if you want to know) to now learning the myriad world of programming in a Unix environment including sorting out the several dozen make files that made up this wonderful project and figuring on what pieces to keep and what to re-write. It was one hell of a learning experience
Fast forward a bunch of years and I am an adjunct professor at a college in NYC. I give out programming assignments to my students and some of the results I get back are nice clean code and others, you guessed it, resemble a plate of pasta.
It must be noted that I did notice a correlation between the students who wrote nice crisp code and had wonderfully organized notes and took an organized approach to problem solving and those who wrote spaghetti code and were more random in their general style of doing things.
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg