Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Spaghetti code...

by davido (Cardinal)
on Oct 09, 2005 at 04:12 UTC ( [id://498505]=poll: print w/replies, xml ) Need Help??

Vote on this poll

Tastes like chicken.
[bar] 7/3%
Smells like tuna.
[bar] 5/2%
Looks like line noise.
[bar] 6/2%
Feels cold and clammy.
[bar] 3/1%
Runs like Montezuma's Revenge.
[bar] 18/7%
Must be kept refrigerated after opening.
[bar] 17/7%
Will be my gift to my successors.
[bar] 31/13%
Was a curse bestowed upon me by my predecessors.
[bar] 45/18%
Is most easily consumed with chopsticks.
[bar] 11/4%
May cause bloating.
[bar] 12/5%
Needs a little salt.
[bar] 14/6%
Back away, close the door, pretend you never saw it.
[bar] 79/32%
248 total votes
Replies are listed 'Best First'.
Re: Spaghetti code...
by BrowserUk (Patriarch) on Oct 09, 2005 at 05:39 UTC

    ...was the working title of a Dan Brown book.

      ...was the working title of a Dan Brown book.

      I don't want to spoil this fine book, but it has a lot to do with this mighty deity...

      Best regards

      -lem, but some call me fokat

      Rule 8: Never code on an empty stomach.

      "This bounty hunter is my kind of scum: Fearless and inventive." --J.T. Hutt
Re: Spaghetti code...
by wolfger (Deacon) on Oct 09, 2005 at 11:35 UTC
      Hey, is that some rasistic slurs on Swedish programmers?

      It is only Swedish chefs that are helt jäkla oförståeliga, sådetså.

Re: Spaghetti code...
by Perl Mouse (Chaplain) on Oct 10, 2005 at 12:44 UTC
    We can conclude from this poll that spagetti coders are much more efficient coders than non-spagetti coders. Just look at the numbers! Since as much code is past on to successors as there is code received from predecessors, we see that (as of this writing) the number of people receiving spagetti code out number the people passing on spagetti code by a factor of more than 2 (18 vs. 8).

    Conclusion, every spagetti coder needs to be replaced by more than two non-spagetti coders, making spagetti coders a much more efficient work force.

    People hiring programmers should take note.

    Perl --((8:>* (Spagetti coder)

      Well said!

          -Bryan

Re: Spaghetti code...
by rir (Vicar) on Oct 09, 2005 at 13:04 UTC
    Even with spaghetti costing over a dollar a pound you still don't want to straighten it all out, clean it all up, check each strand, and put it in a new package; because no matter how well you do all that it still won't be like new. Thank you for not making that an option.

    Backing away is a cowardly, or sensible, reaction.

    If that is not possible refrigeration is needed.

    If it is beyond freezing, throw it out with the moldy quacamole.

    Only serious.

    Be well,
    rir

Re: Spaghetti code...
by zentara (Archbishop) on Oct 09, 2005 at 13:06 UTC
    ..... is an under-appreciated technique for source-protection.

    I'm not really a human, but I play one on earth. flash japh
Re: Spaghetti code...
by BerntB (Deacon) on Oct 09, 2005 at 06:13 UTC
    I'm writing pod and examples for the alpha of my first CPAN module and worry a bit about future criticism. :-)

    That makes it nice to see this now. In three weeks, a voting alternative might have been:

    Spaghetti code ... Is written by BerntB!

    I'll upload some documentation for RFC on Meditations in a couple of days (and there is an intro on my scratchpad).

Re: Spaghetti code...
by tbone1 (Monsignor) on Oct 10, 2005 at 12:33 UTC
    I've often said that, one of these days, I'm going to write a blues song called "Other People's Software".

    --
    tbone1, YAPS (Yet Another Perl Schlub)
    And remember, if he succeeds, so what.
    - Chick McGee

Re: Spaghetti code...
by simon.proctor (Vicar) on Oct 10, 2005 at 14:47 UTC
    Spaghetti code.....

    Is the final revenge for a disaffected programmer who knows they will have left as soon as the code goes live....."well it worked while I was there . . ."

    ;)
Re: Spaghetti code...
by blue_cowdawg (Monsignor) on Oct 11, 2005 at 20:16 UTC

    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
Re: Spaghetti code...
by neversaint (Deacon) on Oct 09, 2005 at 07:03 UTC
    Dear Masters,

    Pardon me for my lack of knowledge. Honestly, I don't get it.
    What's the meaning of "Spaghetti Code"?


    ---
    neversaint and everlastingly indebted.......
      Wiki will tell you

      Spaghetti code is a pejorative term for source code which has a complex and tangled control structure, especially one using many GOTOs, exceptions, threads, or other "unstructured" branching constructs.

      More here...Spaghetti_code

        You can also turn code into spaghetti without any unstructured branching constructs, just by judiciously using horrible coding practices in general. I submit to you a snippet from a perl script I wrote some years ago, which is just downright embarassing these days. Note especially the embedded SQL and HTML (with embedded javascript to boot) in the middle of my perl mere lines apart, the obscure variable names, the direct use of array members and references to them, the sloppy formatting, the ultra-long lines, and the painful use of the ternary ? : operator:

        $ref=$dbh->selectall_arrayref("SELECT transc.id,transc.state,transc.st +art_date,transc.phys_name,transc.mt_name,org.orgname FROM transc JOIN + org ON (transc.org_id = org.id) WHERE ( transc.state = 4 AND transc. +qa_name='$userinfo{name}' ) OR ( transc.state = 2 AND transc.mt_name= +'$userinfo{name}' ) ORDER BY transc.id"); foreach my $x (@{$ref}) { my $compdis = (filesexist($$x[0],"t") ? "" : qq{disabled="disabled"} +); $$x[2]=~s/...$//; $selfjobs .= qq{<tr><td>$$x[0]</td><td>$whichtype{$$x[1]}</td><td>$$ +x[2]</td><td>$$x[5]</td><td>$$x[3]</td><td>$$x[4]</td><td><input type +="button" value="Files..." onclick='window.location.replace("?fa=$$x[ +0]")' /><input type="submit" value="Complete" onclick='setja($$x[0]," +complete")' $compdis /></td></tr>\n}; }
Re: Spaghetti code...
by Zaxo (Archbishop) on Oct 09, 2005 at 13:08 UTC

    . . . is often served with meatball code.

    Oops, didn't see wolfger's.

    After Compline,
    Zaxo

The worst thing..
by moot (Chaplain) on Oct 12, 2005 at 19:13 UTC

    about spaghetti code is how much more spaghetti it begets. In the initial stages, this is known as alpha begetti spaghetti (sorry!).

    Once you find yourself mired in Spagcode, any changes quickly take on the mode of "Crap! this is too much work to do properly by deadline! I'll just put this hacky bit of cruft in here to make it work now, and come back to do it properly later".

    Of course, those who have been in software development long enough to have worked on OPS (Other People's Spaghetti) also know that "later" never comes.. so the hack you quickly threw in to meet the deadline becomes yet more spaghetti for someone else to deal with. Often, that someone else is an older you.

    Eventually you reach a point where it is simpler to declare the spaghetti 'obsolete', and begin work on version 2.

    Yes, this is the bitter voice of experience :)

      It depends.

      Hateful as spaghetti code may be, there’s also the plain fact that it has worked in production for a while and has accumulated various bug fixes too. If you start over from scratch, you have to redo everything, including the parts which happen to be decent (which is the majority of the code even in most “bad” codebases), and you will likely run into half of the same bugs all over.

      You are almost always better off refactoring the spaghetti code iteratively as you work on it. Instead of adding just one more hack to make something work and deferring the proper implementation for later, clean up that one corner of the code you’re directly working on, as far as is sanely possible, and add your change on top of that. The right way to do this, of course, is by writing tests for the part of the code you are about to clean up, so you can be confident that your cleanup doesn’t break anything. Over time, the codebase will slowly tend towards sanity, and as you go along you will progressively accumulate a test suite that will give you confidence to attack the code more aggressively in the more seriously broken parts.

      Most of this work is quite mechanical.

      Very few codebases are so hairy and disastrous that throwing away the good and known working parts they contain is justified.

      Makeshifts last the longest.

Re: Spaghetti code...
by bluto (Curate) on Oct 11, 2005 at 19:18 UTC
    When I first started programming years ago I liked assembler for it's sheer spaghetti beauty. But after I found that SNOBOL allowed two gotos at the end of each line of code (i.e. one on success and one on failure), I was in love...
Re: Spaghetti code...
by steelrose (Scribe) on Oct 12, 2005 at 17:02 UTC
    ... is usually the result of too many cooks in the program.
    If you give a man a fish he will eat for a day.
    If you teach a man to fish he will buy an ugly hat.
    If you talk about fish to a starving man, you're a consultant.
Re: Spaghetti code...
by Anonymous Monk on Oct 10, 2005 at 04:28 UTC
    I agree about the source protection... coworkers avoid it like the plaque. ...is fun to break into small sticks and crunch.
Re: Spaghetti code...
by rinceWind (Monsignor) on Oct 11, 2005 at 11:40 UTC

    This poll reminds me that one variety of spaghetti, the fine noodle stuff, is called vermicelli. If you translate this literally to English, it means worms.

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

Re: Spaghetti code...
by saskaqueer (Friar) on Oct 11, 2005 at 18:11 UTC

    I voted for "is most easily consumed with chopsticks". My version of this phrase doesn't mean 'consume' as in 'to eat', but more so 'to destroy'. I had a vision upon reading the chopsticks line: becoming frustrated by the spaghetti code while eating some delicious chow mein. Stabbing first the monitor, then the hard disk, with the chopsticks, thus eliminating the spaghetti code. Yeah, that'll teach em!

Re: Spaghetti code...
by TedPride (Priest) on Oct 11, 2005 at 18:37 UTC
    It's no use trying to understand spaghetti code. Just dump it and rewrite.
Re: Spaghetti code...
by fraktalisman (Hermit) on Oct 12, 2005 at 07:53 UTC
Re: Spaghetti code...
by He_Who_Is_Pale (Sexton) on Oct 12, 2005 at 14:30 UTC
    ...is a challenge!

View List Of Past Polls


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-03-19 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found