What is Spaghetti Code?
Code that is unstructured and difficult to maintain is sometimes referred to, insultingly, as spaghetti code. In most cases, spaghetti code results from too many goto
statements, causing the flow of control to jump abruptly across constructs. The term's origin comes from the nature of such code to be "twisted and tangled" like a bowl of spaghetti.
The paradigm of structured programming focuses on making programs using sequences of single-entry single-exit blocks. Reducing the prevalence of spaghetti code, notably by forbidding using the goto
keyword, was one of the fundamental aims behind its development.