Baklava code

“Spaghetti code” is a well-known phrase for software with tangled logic, especially legacy code with goto statements.

The term “lasagna code” is not nearly as common. I first heard it used to describe code with too many architectural layers. Then I found the following older reference to lasagna code with a different slant on the term.

Lasagna code is used to describe software that has a simple, understandable, and layered structure. Lasagna code, although structured, is unfortunately monolithic and not easy to modify. An attempt to change one layer conceptually simple, is often very difficult in actual practice.

Since “lasagna code” has a different usage, I propose the term “baklava code” for code with too many layers.

Baklava. Photo credit Wikipedia

Baklava is a delicious pastry make with many paper-thin layers of phyllo dough. While thin layers are fine for a pastry, thin software layers don’t add much value, especially when you have many such layers piled on each other. Each layer has to be pushed onto your mental stack as you dive into the code. Furthermore, the layers of phyllo dough are permeable, allowing the honey to soak through. But software abstractions are best when they don’t leak. When you pile layer on top of layer in software, the layers are bound to leak.

Related posts

11 thoughts on “Baklava code

  1. This immediately made me think of some of the WSGI apps I’ve been digging through lately. It’s a useful and conceptually cool standard, but I’m finding that it’s also very easy to abuse.

  2. If spaghetti, lasagna, and baklava are metaphors for bad programming, then what food represents good programming?

    And to answer my own silly question: How about Mexican food. Seven basic ingredients served up in a multitude of different ways depending on the dish to be served (or task to be coded).

  3. I like the Mexican food analogy, but I immediately thought of a hamburger: You’ve got the meat (the interesting code that the program is all about), the buns (a convenient, portable UI), and the toppings (interchangeable functions for pre- or post-processing). It works really nicely for the kind of code that I end up writing (data analysis/machine learning), where there’s one key idea that the whole algorithm is based on, with a whole lot of necessary but less-important code that wraps it.

  4. I’m disappointed you didn’t stick with the Italian theme; something that conjours up images of chaos in my head

  5. Oh man, this reminds me…

    One time, I had to work on some guy’s web-based scheduling application that he wrote in Perl. I’m something of a Perl guru (although experiences with other peoples’ Perl code have led me to avoid the language now), but wow. There were like ten layers of abstraction in the stupid thing, so it took me days to figure out where the real work was being done. The dude who wrote it was an eccentric genius, but his program was horribly over-engineered to the point of being unmaintainable. It felt like it was written so that if you wanted to, you could set it up to work on a completely different (non-web) interface, which was completely outside of the program’s design requirements.

    So yeah, Baklava code. Excellent analogy. :)

  6. When talking to my students, I use the term of MacDo Code.
    More international than Baklava, and more dangerous too.

  7. A coworker coined the term ravioli code for systems without a recognizeable organization of its class structure: just plenty of objects in tomato sauce.

  8. I think the pun about baklava leaking is a bit of a non sequitur. ISTM, leaks (a kind of bug) are orthogonal to the amount of abstraction of a given piece of code. If the code has “too much” abstraction, that doesn’t mean that it is buggy, or leaks resources. I think the top-down approach can work well, depending on the objective, and the programming language of the implementation, although it sometimes results in (too) many layers of abstraction. It depends what you are doing.

Comments are closed.