What’s the difference between spaghetti code, lasagna code, ravioli code, and pizza code?

222 views

I’m starting to get into coding and these concepts make little sense to me.

In: 0

5 Answers

Anonymous 0 Comments

Those are just insider jokes, they aren’t important in your coding progress. Although they are fun!

– spaghetti code: just messy code, hacks building upon other hacks, whatever it takes to achieve the purpose. Usually unreadable a week after.
– lasagna code: this is referring to the concept of layers of abstraction. Which is usually a good thing, but when we’re talking about lasagna code – it’s usually abstraction done to the absurd degree.
– ravioli code: making your codebase consist of many self-contained pieces, independent from each other. Which is also usually a good thing, but just like with lasagna – it can get absurd.
– pizza code: don’t know this one.

Anonymous 0 Comments

Spaghetti code is the only one of these terms that I’ve actually seen. Generally means code that isn’t structured well and is hard to follow. I guess the comparison is like trying to untangle individual noodles in a bowl of spaghetti…? Never really thought about it that much.

Source: been in industry for like 11 years

Anonymous 0 Comments

Lasagna code: I hate Mondays

Ravioli code: Little surprises hidden everywhere

Pizza code: Mgmt won’t give us a raise, but here comes the pizza

Anonymous 0 Comments

As people said, spaghetti code is the main term there, and the rest are jokes about the term spaghetti code.

Spaghetti code makes more sense historically, in terms of assembly and languages that rely on the “go to” instruction. Modern languages don’t use go to, and have loops and stuff instead.

If you imagine messy code written that way, and drawing lines to show the paths in can take, “spaghetti” is a much more apt descriptor.

Anonymous 0 Comments

They are all metaphors to describe source code that is poorly designed in different ways. These are all subjective terms so the specifics will differ for each person.

**Spaghetti code** is really the only commonly used term. It originally meant code whose flow of execution is too complicated, traditionally this was caused by excessive use of GOTO statements to jump to different lines of code. Modern languages have better ways to deal with this (control flow: if, then, else, for, while, exit, continue etc) and possibly don’t even have an equivalent of the GOTO keyword. Nowadays it generally just means code that is difficult to read or follow; usually as a result of poor planning, tacking on changes instead of refactoring, and technical debt. The analogy to spaghetti is because reading the code is like following a string of spaghetti as it weaves and intertwines with other noodles.

The other terms are more recent, and nobody really uses them in practice. They’re all just playing off the same joke of comparing code to Italian food.

**Lasagne code** means code that has too many layers of abstraction. Abstraction is good, but too much of it means you’re going 20 layers up before you find the code that actually does the thing you’re looking for. The “layers” might be function calls, parent classes, event emitters etc depending on the system design, eg. Factory Pattern. Obviously because a lasagne dish is composed of layers of pasta sheets.

**Ravioli code** is a system that’s overly engineered to have a specific standalone component for every little function. Think microservice architecture taken too far. Ravioli pasta is small independent parcels of meat, cheese, vegetables etc.

**Pizza code** is an architecture that’s too flat. This is basically the opposite extreme to lasagne or ravioli; instead of layers of abstraction or independent standalone components, you have one big system with a lot of interdependency or thousands of lines of code in one big class etc. Like spaghetti code, pizza code is usually an outcome of poor design or lack of design, rather than over-engineering. It’s also not mutually exclusive to spaghetti, because a code base might both be too flat and difficult to untangle. Pizza obviously because it stuffs many ingredients into a single flat dish.

[This page](https://www.techtarget.com/searchsoftwarequality/tip/Fix-spaghetti-code-and-other-pasta-theory-antipatterns) describes these terms further and even mentions a few more. But remember, beyond *spaghetti code* these terms aren’t really used or even important. However as you become more experienced at coding you should definitely learn about the various anti-patterns that they describe, so that you can avoid them.