views:

503

answers:

6

According to Wikipedia, the term was originally coined by a database expert Joe Celko in 1982 and here's a quote from his 1997 article revealing what he meant by it: "The standard [structured programming] solution was to replace the GOTOs with nested IF-THEN-ELSE statements and switches that were layered so deep and had so much redundancy that you had a path of control that looked like a plate of lasagna instead."

The same Wikipedia entry however, defines the term differently, clearly referring to multi-layered applications: "... different subsystems, such as ... web application code, business logic, and a relational database." The term's meaning has thus evolved as programmers developed new methodologies and architectures.

I can think of two modern definitions of "lasagna code":

  1. layers of a software application that are excessive, over-engineered or trivial (obviously)
  2. layers of a software application lacking unit tests with proper isolation. The developers only tested the system by slicing through and consuming multiple layers at once.

The term obviously means criticism (much like you may criticize my stuff by calling it "spaghetti code"). But what does it mean to you and when would you use it?

+1  A: 

To me, it means layered for no good reason.

MusiGenesis
I thought that's what SevenLayerCake Code was for?
Sneakyness
Great. So much for the diet. :)
MusiGenesis
A: 

I've never heard of lasagna code before, but the first thing that came to mind was "spaghetti code". My guess was parts of it were all over the place, but the majority was a cohesive unit. Not a bad a spaghetti code, but not good enough not to get called out.

easement
+4  A: 

Too many GOTOs == Spaghetti Code

Too many IF-THEN-ELSE/Switch == Lasagna Code

:)

Frozenskys
Excessive use of pipes - Penne Code
Jack Leow
Excessive threading - Capellini Code :)
Jack Leow
Excessive use of the Spring Framework - Fusilli Code
Jack Leow
Excessively componentized - Ravioli Code
Jack Leow
OK, I'm done. Now I'm hungry.
Jack Leow
+1  A: 

For some reason, this question made me think of Garfield.

Jack Leow
+1  A: 

Spaghetti code reference at Wikipedia has this to say,

Lasagna code is a type of program structure, characterized by several well-defined and separable layers, where each layer of code accesses services in the layers below through well-defined interfaces.
The term is in comparison with spaghetti code, comparing program structure to pasta.

The analogy stems from the layered structure of a plate of lasagna,
where different ingredients (meat, sauce, vegetables, or cheese) are each separated by strips of pasta.

nik
+1  A: 

A well made lasagna, the kind my wife makes, is well layered and neat, spaghetti on the other hand is a tangled confusing mess, so I would think that the latter would be an insult while the former would just be a way of describing code that has been developed in isolated layers. I guess MVC would be considered a lasagna approach to programming, but it sounds silly and I would never use it. Besides, if you told a fat programmer that he writes lasagna applications you run the risk of offending the poor guy.

It could also refer to code written by italians I suppose :)

Gary Benade