Talk:Spaghetti code
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)
![]() | Spaghetti with meatballs (programming) was nominated for deletion. The discussion was closed on 23 September 2009 with a consensus to merge. Its contents were merged into Spaghetti code. The original page is now a redirect to this page. For the contribution history and old versions of the redirected article, please see its history; for its talk page, see here. |
![]() | Computing Start‑class High‑importance | |||||||||
|
![]() | Computer science Start‑class Mid‑importance | ||||||||||||||||
|
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? — 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 [1] it is unclear what it means. It was deleted from Wikipedia: see Wikipedia: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)
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 goto
version of a for
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 select
(switch
, case
depending on language) clauses emulated by goto
and abnormal jumps within that select clause. I've programmed in such code once, created by an optimistic non-programmer. Rursus dixit. (mbork3!) 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!
10 i = 0
20 i = i + 1
30 PRINT i; " squared = "; i * i
40 IF i >= 10 THEN GOTO 60
50 GOTO 20
60 PRINT "Program Completed."
70 END
10 FOR i = 1 TO 10
20 PRINT i; " squared = "; i * i
30 NEXT i
40 PRINT "Program Completed."
50 END
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)
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)
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. Mindmatrix 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)