Spaghetti Code

dead-metaphor Food and CookingSoftware Programs

Categories: software-engineering

What It Brings

Tangled pasta maps onto tangled control flow. The metaphor is instantly legible to anyone who has pulled a forkful of spaghetti from a plate and watched half the dish follow: you cannot extract one strand without dragging everything else with it. This is precisely the experience of reading code with unstructured jumps, deeply nested conditionals, and invisible dependencies.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The term appears in print as early as 1978 in the proceedings of the ACM, though it was certainly in oral use before that. It emerged alongside the structured programming movement of the 1960s and 1970s, when Dijkstra’s “Go To Statement Considered Harmful” (1968) gave the programming community a villain (the goto) and the spaghetti metaphor gave them a name for the crime scene. The metaphor was a rhetorical weapon in the structured programming wars: if your code uses gotos, it’s spaghetti, and spaghetti is disgusting.

The food-family extensions (lasagna, ravioli, baklava) emerged later in blog posts and conference talks, as developers realized that structure itself could be pathological — you could have too much of it, not just too little.

References

Related Mappings