Talk:Spaghetti code

199.29.247.140 Example?
Is what 199.29.247.140 added really spaghetti code? I'd just call it bad code, because there's no noodle like loops of goto-ing and whatnot... --Carl 13:49, 13 Oct 2004 (UTC)
 * I agree. It's hardly a good example of spaghetti code. I removed it. --Neg 01:21, 27 Nov 2004 (UTC)

Is there really any need for that picture of a bowl of spaghetti?
 * I guess looking at the spaghetti aids in understanding the chaotic nature of spaghetti code. Plus its humourous so why not. JesseHogan 07:56, 15 July 2005 (UTC)
 * Those pictures are much in help to understand what spaghetti code is. There could be bowl of Ravioli picture too, coz i don't know what ravioli is, so will have to search for it seperately Kiaurutis (talk) 21:20, 7 February 2011 (UTC)

assembly and function calls
While many assembly languages have a function stack, and apparent function calls, these are just a thin wrapper for the goto statement. They store the original location of the program counter in order to return to it later.
 * How is this significantly different from a function call in higher level languages? &mdash; The Storm Surfer 20:55, 18 July 2005 (UTC)


 * Moreover, spaghetti code is not the sine qua non of programming in assembly language, FORTRAN and early BASICs. With proper early training and mental discipline, anyone can write structured code in any computer language.  My college instructor in the early 1970s referred to such programming as "good programming", long before the catch phrases "structured programming" and "object-oriented programming" came into widespread use. --QuicksilverT @ 18:10, 29 November 2005 (UTC)


 * The quote above is not accurate. It should mention the "gosub" statement, not a "goto". A gosub implies a return: "go to subroutine". A "goto" means you never come back.


 * Actually, the use of subroutine calls (such as the primitive gosub) helps eliminate spaghetti code. --Uncle Ed 01:08, 6 April 2006 (UTC)

PJTraill 15:49, 8 April 2006 (UTC) I have largely rewritten this section in accordance with the above observations.

Lo-mein code
A variation of spaghetti code with unreadable and/or outdated and misleading comments. Often includes numerous macros that call other macros that modify global variables.


 * PJTraill 15:59, 8 April 2006 (UTC) Has anyone got a source for this? Does anyone know people who use the term? At it is unclear what it means. It was deleted from Wikipedia: see Articles_for_deletion/Lo-mein_code.

NPOV: line numbering
I don't believe the 2 code fragments really illustrate spaghetti code in a fair way: it makes it seem as though the older style of BASIC, especially the line numbering, is the problem. The 2 code fragments should ostensibly be be written in the same style. I like seeing the BASIC, lord knows it facilitated more than its share of bad code, but as I no longer have access to an interpreter I don't think I can come up with a fully functional "structured" example. Ewlyahoocom 18:53, 11 February 2006 (UTC)

Another example
Just try to figure out how this baby gets the sorting done (it looks like shell sort). It's converted from BASIC to QBASIC. I think it as from a library book I once read when I was little. --Zom-B 00:12, 05 November 2006 (UTC)

SCREEN 0 INPUT "How many numbers to sort? "; T DIM n(T) FOR i = 1 TO T   PRINT "NUMBER:"; i    INPUT n(i) NEXT i 'Calculations: C = T E180: C = INT(C / 2) IF C = 0 THEN GOTO C330 D = T - C E = 1 I220: f = E F230: g = f + C SWAP n(f), n(g) f = f - C IF f > 0 THEN GOTO F230 E = E + 1 IF E > D THEN GOTO E180 GOTO I220 C330: PRINT "The sorted list is" FOR i = 1 TO T   PRINT n(i) NEXT i

Spaghetti code vs monolithic code
I'm looking for the proper terminology that describes code that isn't a jumbled mess per se, but is hard to decouple or modularize. Perhaps this goes hand-in-hand with spaghetti code, but for example monolithic kernel doesn't seem to imply sloppy coding practice. Can the article be made to clarify if and how these things are different? Ham Pastrami (talk) 12:18, 3 April 2008 (UTC)


 * My aunt has been programming when the term was coined, and according to her the term spaghetti code means exactly that and has no connection to control flow at all. The metaphor makes *much* more sense this way: When you have a lump of spaghetty, pulling at any specific noodle will get you the whole ball. —Preceding unsigned comment added by 84.187.101.243 (talk) 01:17, 3 July 2008 (UTC)


 * Bollocks. Spaghetti code means a tangled indecipherable mess. That's what it has always meant. 194.213.49.62 (talk) 14:37, 30 January 2012 (UTC)


 * NO, they are different things. Monolithic refers to the modular structure of a program. More clearly when there is just one module. Although one can divide the program in several modules, those modules may not be of general use. In such case the program is logically monolithic. I hope that those programs are unthinkable for today programmers, because the majority learn OO languages, where modularization and encapsulation is the normal design in the mind of the programmer.  For the spaghetti, code see my comment about "spaghetti flow diagrams."  — Preceding unsigned comment added by 189.178.45.137 (talk) 05:28, 31 January 2016 (UTC)

The Example
The 2 edits by 81.226.168.117 on 11 February 2007 seem to have "fixed" the example of bad code, by putting the commands in a logical order, the same as if it used FOR loops. It is now fairly readable, and its operation obvious, which surely defeats the object of the example, which is meant to show the confusing nature of spaghetti code. I suggest it should be changed back. 131.111.197.43 (talk) 17:56, 22 October 2008 (UTC)

The plate of spaghetti is technically a bowl of spaghetti.
The rims on the dish in the picture raise up, you see. If the dish were a plate, the rims would be on nearly the same level of the base of the dish. But they're not. The dish is very clearly a bowl. Is it possible someone change this? 71.238.211.166 (talk) 20:04, 29 November 2008 (UTC)

I agree, it definitely looks like a bowl to me. Someone should fix this. 78.82.141.50 (talk) 14:54, 27 June 2009 (UTC)

Bowl or plate - are the pasta pictures even necessary at all? Probably not. —Preceding unsigned comment added by 192.158.61.172 (talk) 19:30, 30 November 2009 (UTC)

I agree, Spaghetti picture is really not necessary.Ndkl (talk) 12:18, 13 May 2011 (UTC)
 * i don't agree. the pasta pictures bring some humour and good analogies to the technicalities of "spaghetti, ravioli and lasagna code". love it! --Phneutral (talk) 11:53, 4 October 2011 (UTC)

Source for "Spaghetti with meatballs"
Does anyone know of a source that defines "Spaghetti with Meatballs"? I've been looking but I can't find one and I think one should be added. 173.79.74.195 (talk) 03:57, 17 October 2011 (UTC)

Example again
I think the example of "Spaghetti code" is meek - it's if the example given doesn't quite qualify, since it is just the  version of a   loop. Examples of real spaghetti code should instead provide violation of best practice programming structures, such as jumps into loops, worse, jumps into a block from outside, elaborate 8-loops (instead of a round loop), and  (,   depending on language) clauses emulated by   and abnormal jumps within that select clause. I've programmed in such code once, created by an optimistic non-programmer. Rursus dixit. ( m bork3 !) 14:14, 11 March 2012 (UTC)

I'm also an expert of programming, that's why I don't need to fear of GOTO. It is not made by the devil. It was invented at the earlier times, following the machine coded structure, where there isn't any other option. Later the new languages began to support the structured programming, but you also can write structured programs with GOTO, without DO and others. Yes. The structured programming means to create your program from small elements. A local loop can be done with GOTO very clearly if you don't have other options.

But for God's sake, the example I found here is WRONG! The two codes are not equivalent! The results of them are equal. Now. Type 0 instead of 10 and go ahead. This is a really awkward fail of teaching structured programming. - Orion 8 (talk) 02:04, 27 August 2012 (UTC)


 * I'm not sure what your point here is. It seems like the results are the same. Or is your point that the "spaghetti" example is really not an example of spaghetti at all? I agree with you, it would not have been spaghetti in some year before BASIC had a FOR loop; but today, I think it would qualify as such. Nobody said GOTOs are from the devil, they do have their uses (few and far between as they are). On the contrary, I actually think this is a good simple example of how you can use constructs of a language to make a program more spaghetti-like or less spaghetti-like. You are welcome to add your own example of spaghetti and non-spaghetti code. Fool4jesus (talk) 19:54, 11 September 2012 (UTC)


 * I agree that the example is pretty weak. This is sadly very common when spaghetti code is explained. It often gives the impression that the gotos themselves causes spaghetti code, which is certainly not the case. In this case, the spaghetti example is not complex enough to fully show the problem. If I should propose a very naïve definition of spaghetti code, I would propose "code that cannot be transformed into high-level loops with ease". 192.71.194.251 (talk) 09:31, 4 April 2017 (UTC)

assembly languages have for and while statements?
Of assembly languages, the article says, "... they are low-level programming languages where equivalents for structured control flow statements such as for loops and while loops exist, but are often poorly understood by inexperienced programmers." Is this true? I thought for and while statements were emulated through conditional branching. --Allen (talk) 21:56, 22 December 2012 (UTC)

At least as far as MIPS and x86 assembly are concerned, there's no direct way to achieve loops; you'd usually just use some counter/flag variable and (depending on the assembly) use something like a combination of set less/greater than and branch (not) equal based on the result to a label that jumps you out of the loop or to the beginning again. Are there any sources that indicate that many assembly programmers don't know how to implement these structures? 73.38.177.249 (talk) 18:41, 18 March 2015 (UTC)

Lasagna Code
It's pretty silly that the article gives an exact year when the tangential phrase 'lasagna code' was coined, while nothing at all is said about the origin of the term covered by the main article, "spaghetti code". Or what am I missing? Toddcs (talk) 21:54, 12 November 2013 (UTC)


 * Probably because nobody ever bothered researching it or adding it to Wikipedia. I've added a history section, though I doubt it covers the earliest use, and misses much of the term's use from the 1960s and early 1970s. Mind  matrix  01:07, 13 November 2013 (UTC)

Macaroni code
Hi, folks. I just added a new section on "macaroni code," but I'm now having second thoughts because the term does not appear to be in common usage. Google's Ngram viewer indicates that it was far more common in the 1950s: https://books.google.com/ngrams/graph?content=macaroni+code but not what it meant at that time. The only other definition for the term I can find is this one: http://theburningmonk.com/2010/01/buzzword-buster-macaroni-code/ which differs from the one I have provided.

Before you reflexively delete my addition, though, please consider the article on Macaronic language that inspired the edit, so you can see where I'm coming from. I believe the HTML/PHP/SQL/JavaScript example I have provided is at least as macaronic as any of the examples given in that article, and so even though the term is not in common usage, I feel that it belongs in the article.

Note, for instance, that the terms "ravioli code" and "lasagna code" are not found in any of the books Google has indexed: https://books.google.com/ngrams/graph?content=ravioli+code%2Clasagna+code — Preceding unsigned comment added by Ben Stallings (talk • contribs) 18:46, 7 January 2014 (UTC)

Is this a joke?
"Ravioli code", "Spaghetti with meatballs"? Really? This is surely an analogy taken far, far too far. Only "Lasagna" and "Macaroni" have citations, but these are weak at best. I propose the entire "Related terms" section is removed, or at very least remove the images of the plates of food, they contribute nothing and add to the satirical feel of the page.

Discussion welcome. — Preceding unsigned comment added by 209.251.196.62 (talk) 16:05, 28 January 2014 (UTC)


 * I agree! What is going to be next, "chow-main"? Who invented those myths?


 * LOL! Chow mein...that would be funny. On a more serious note, if no citations can be found for it, it may be best to remove the content, as it would likely be a hoax. Me, Myself &#38; I (talk) 06:44, 31 January 2016 (UTC)

Data flow diagrams and spaghetti code
Spaghetti code is not just the use of GOTOs, one can write perfectly structured code using GOTOs, some correspond to the structures of decision (if-then-else) and iteration (while, repeat-until, for-next), other more complex correspond to coroutines. The problem with the use of GOTOs rely one it's origin.

In the context of structured programming, one can design a program by composing the basic structures of imperative languages: assignment, decision, sequence, iteration, abstraction (the use of subroutines/functions). The programmer has to ensure that the program, i.e. the composition of the instructions derived from those structures, transform the initial state of the program (according to the specification) to stop with a state which corresponds to the specified result. If the program was conceived in such way, then implemented in a language which lacks such structures, like the earl BASIC, Fortran, COBOL or an assembler, that does not mean that the program became spaghetti. Or in a more contemporary context, you can design a program using the continuation passing style, obtaining a program with GOTOs, but perfectly structured.

Previous to structured programming, the story was different, many programs were conceived drawing flow diagrams. The programmers that used such technique did not follow the neat composing of instructions. The resulting flow diagrams, had a clumsy shape, hard to read, they were not planar graphs, because they could not be written without crossing lines. Those diagrams seem spaghetti, that is the origin of the term. The corresponding programs had lots of GOTOs, but one could not easily understand them, because it was not clear their structure. More over, on those days many programmers thought that the diagrams where sufficient to document the programs.

As far as I remember, a long time ago, this entry did not have such unfounded statements of different classes of pasta. Instead it had a picture of an spaghetti diagram, to illustrate what this term is about.

I ignore why it was deleted, maybe due to a justified reason like a copyright issue, or just for some kind of sabotage. If someone want to search in the history (about 15 years ago) to know why to restore it, that is one way, or you can work my explanation to rewrite this article. I am tempted to ask it's deletion.
 * See Assemblers and linkers (Part 2: The Assembly Process), p. 16 and Call graph - motion on calls inside sections/labels. RippleSax (talk) 09:29, 18 March 2016 (UTC)

Spaghetti images needed
Without images of Spaghetti, the concept of Spaghetti code can be beyond utterly opaque for some Wiki readers.

Failing to show images of this culinary oddity discriminates against many English as a 2nd Language readers, as this "Turing State Machine Concept" is really hard to understand even for a substantial and substantive percentage of the English global community.

Wikipedia already has a long term and ongoing bad rap for being the Ground Zero for public opinion manipulation when it comes to entire classes of articles.

There is no percentage yet derived, but possibly 10% to 22.5% of Wiki articles should not be read (or used) due to the beyond toxic manipulation originating from governments, corporations and religious groups. This includes a great number of scientific and technical articles that really should be exempted from this problem but because of the Wiki RealPolitik are not.

This article should not be one of them...

Eyreland (talk) 03:15, 24 October 2018 (UTC)