tags:

views:

411

answers:

5

I have seen in many forums and technical sites the expression "Code of our project is spaghetti"

What is the meaning of this expression?

+2  A: 

Simply that is is messed up and convoluted and intertwined and hard to trace an individual strand.

PurplePilot
+9  A: 

http://en.wikipedia.org/wiki/Spaghetti_code

Brian
+7  A: 

"Spaghetti code" means that the flow/branching in your code is intertwined.

You can see spaghetti code anytime you can have trouble following the flow of your program. Some examples are with gotos, exceptions, threads, or other branching mechanisms available in your programming language.

An example with gotos:

//now entering spaghetti code...

label1:
//some code
goto label3;

label2:
//some code
goto label4;

label3:
//some code
goto label2;

label4:

//now leaving spaghetti code...

See Wikipedia for more examples on spaghetti code and for other pasta coding terms less commonly used :).

Brian R. Bondy
I like the comments above//now entering and leaving spaghetti code.
ckv
Althrough people often refer to spaghetti-code as using a lot of `goto's`, today spaghetti code is "achived" by using fucked up `exceptions` (which are even worse than gotos) and enabling classes in undefined states.
Viktor Sehr
+18  A: 

Large monolithic programs are like a plate of spaghetti; pull it here and something moves on the other side.

This is the earliest reference I know of the spaghetti code simile. It's from Program Style, Design, Efficiency, Debugging, and Testing (1974) by Dennie Van Tassel.

Spaghetti code refers to code that is so intricate and poorly organized that changing any part of it is likely to affect functionality other than that which you intended to change.

Bill Karwin
huh, that's not what I've ever meant by spaghetti code... I always mean goto-s...
Brian Postow
@Brian Postow: It's certainly easy to create spaghetti code when using `goto` poorly. But the original meaning is broader.
Bill Karwin