Spaghetti code

From Wikipedia, the free encyclopedia

Spaghetti code is a pejorative phrase for unstructured and difficult to maintain source code, broadly construed. Spaghetti code can be caused by several factors, such as volatile project requirements, lack of programming style rules, and insufficient ability or experience.[1]


Code that overuses GOTO statements rather than structured programming constructs, resulting in convoluted and unmaintainable programs, is often called spaghetti code.[2] Such code has a complex and tangled control structure, resulting in a program flow that is conceptually like a bowl of spaghetti, twisted and tangled.[3] In a 1980 publication by the United States National Bureau of Standards, the phrase spaghetti program was used to describe older programs having "fragmented and scattered files".[4] Spaghetti code can also describe an anti-pattern in which object oriented is written in a procedural style, such as by creating classes whose methods are overly long and messy, or forsaking object oriented concepts like polymorphism.[5] The presence of this form of spaghetti code can significantly reduce the comprehensibility of a system.[6]


It is not clear when the phrase spaghetti code came into common usage; however, several references appeared in 1977 including Macaroni is Better Than Spaghetti by Steele published in Proceedings of the 1977 symposium on artificial intelligence and programming languages. In the 1978 book A primer on disciplined programming using PL/I, PL/CS, and PL/CT, Richard Conway used the term to describe types of programs that "have the same clean logical structure as a plate of spaghetti",[7] a phrase repeated in the 1979 book An Introduction to Programming he co-authored with David Gries.[8] In the 1988 paper A spiral model of software development and enhancement, the term is used to describe the older practice of the code and fix model, which lacked planning and eventually led to the development of the waterfall model.[9] In the 1979 book Structured programming for the COBOL programmer, author Paul Noll uses the phrases spaghetti code and rat's nest as synonyms to describe poorly structured source code.[10]

In the Ada – Europe '93 conference, Ada was described as forcing the programmer to "produce understandable, instead of spaghetti code", because of its restrictive exception propagation mechanism.[11]

In a 1981 computer languages spoof in The Michigan Technic titled "BASICally speaking...FORTRAN bytes!!", the author described FORTRAN as "proof positive that the cofounders of IBM were Italian, for it consists entirely of spaghetti code".[12]

Related phrases

Ravioli code

Ravioli code is a term specific to object-oriented programming. It describes code that comprises well-structured classes that are easy to understand in isolation, but difficult to understand as a whole.[13]

Lasagna code

Lasagna code refers to code whose layers are so complicated and intertwined that making a change in one layer would necessitate changes in all other layers.[14]

See also


  1. ^ Markus, Pizka (2004). "Straightening spaghetti-code with refactoring?" (PDF). Software Engineering Research and Practice: 846–852. Retrieved 5 March 2018. 
  2. ^ Cram, David; Hedley, Paul (2005). "Pronouns and procedural meaning: The relevance of spaghetti code and paranoid delusion" (PDF). Oxford University Working Papers in Linguistics, Philology and Phonetics. 10: 187–210. Retrieved 5 March 2018. 
  3. ^ Horstmann, Cay (2008). "Chapter 6 - Iteration". Java Concepts for AP Computer Science (5th ed. [i.e. 2nd ed.]. ed.). Hoboken, NJ: J. Wiley & Sons. pp. 235–236. ISBN 978-0-470-18160-7. Retrieved 2 January 2017. 
  4. ^ United States National Bureau of Standards (1980). ASTM special technical publication. United States Government Printing Office. 
  5. ^ Moha, N.; Gueheneuc, Y. G.; Duchien, L.; Meur, A. F. Le (January 2010). "DECOR: A Method for the Specification and Detection of Code and Design Smells". IEEE Transactions on Software Engineering. 36 (1): 20–36. doi:10.1109/TSE.2009.50. ISSN 0098-5589. Retrieved 5 March 2018. 
  6. ^ Abbes, M.; Khomh, F.; Gueheneuc, Y. G.; Antoniol, G. (2011). "An Empirical Study of the Impact of Two Antipatterns, Blob and Spaghetti Code, on Program Comprehension". 2011 15th European Conference on Software Maintenance and Reengineering: 181–190. doi:10.1109/CSMR.2011.24. Retrieved 5 March 2018. 
  7. ^ Conway, Richard (1978). A primer on disciplined programming using PL/I, PL/CS, and PL/CT. Winthrop Publishers. ISBN 0-87626-712-6. 
  8. ^ Conway, Richard; Gries, David (1979). An Introduction to Programming (3rd ed.). Little, Brown. ISBN 0-316-15414-8. 
  9. ^ Boehm, Barry W. (May 1988). "A spiral model of software development and enhancement". IEEE Computer. IEEE. 21 (2): 61–72. doi:10.1109/2.59. 
  10. ^ Noll, Paul (1977). Structured programming for the COBOL programmer: design, documentation, coding, testing. M. Murach & Associates. 
  11. ^ Schwille, Jürgen (1993). "Use and abuse of exceptions — 12 guidelines for proper exception handling". Lecture Notes in Computer Science. Ada – Europe '93 (Proceedings). 688. Springer Berlin Heidelberg. pp. 142–152. doi:10.1007/3-540-56802-6_12. 
  12. ^ MTSBS[clarification needed] (March–April 1981). "BASICally speaking...FORTRAN bytes!!". The Michigan Technic. College of Engineering, University of Michigan. 99 (4). 
  13. ^ Troyer, O. De (13 May 1991). "The OO-binary relationship model : A truly object oriented conceptual model". Advanced Information Systems Engineering. Springer, Berlin, Heidelberg: 561–578. doi:10.1007/3-540-54059-8_104. Retrieved 5 March 2018. 
  14. ^ Tomov, Latchezar; Ivanova, Valentina (October 2014). "Teaching Good Practices In Software Engineering by Counterexamples" (PDF). Computer Science and Education in Computer Science (1): 397–405. Retrieved 5 March 2018. 

External links

  • Go To Statement Considered Harmful. The classic repudiation of spaghetti code by Edsger Dijkstra
  • We don't know where to GOTO if we don't know where we've COME FROM by R. Lawrence Clark from DATAMATION, December, 1973
  • Refactoring Java spaghetti code into Java bento code separating out a bowl full of code from one class into seven classes
  • Objects and Frameworks – Taking a Step Back by Brian Rinaldi
  • Programming Pasta - Spaghetti, Lasagna, Ravioli and Macaroni Code
  • Pasta Theory of Programming
  • Spaghetti Code: Detangling Life and Work with Programmer Wisdom (English Edition)
Retrieved from ""
This content was retrieved from Wikipedia :
This page is based on the copyrighted Wikipedia article "Spaghetti code"; it is used under the Creative Commons Attribution-ShareAlike 3.0 Unported License (CC-BY-SA). You may redistribute it, verbatim or modified, providing that you comply with the terms of the CC-BY-SA