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.
Video Spaghetti code
Meaning
Code that overuses GOTO statements rather than structured programming constructs, resulting in convoluted and unmaintainable programs, is often called spaghetti code. 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. 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". 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. The presence of this form of spaghetti code can significantly reduce the comprehensibility of a system.
Maps Spaghetti code
History
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", a phrase repeated in the 1979 book An Introduction to Programming he co-authored with David Gries. 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. 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.
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.
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". Popularity of this term for unstructured code is at least partly due to the fact that it was two Italian mathematicians (Corrado Böhm and Giuseppe Jacopini) who published the "Structured Program Theorem" in 1966 that was later cited two years later by Edsger Dijkstra in his open letter (to which an editor added the title, "GO TO Considered Harmful").
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.
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.
See also
- Big ball of mud, a piece of software with no perceivable architecture
- International Obfuscated C Code Contest, a competition to produce pleasingly obscure C code
- Write-only language, a language with such bizarre syntax that resulting code is incomprehensible
References
- This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
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)
Source of the article : Wikipedia