Corollarium Dev Blog

Thoughts on software development redirected straight from /dev/null

The pasta theory of code

I don’t know why, but most new programmers I’ve been talking to never heard of spaghetti code. Wikipedia has a nice definition for it:

Spaghetti code is a pejorative term for source code that has a complex and tangled control structure, especially one using many GOTOs, exceptions, threads, or other “unstructured” branching constructs. It is named such because program flow tends to look like a bowl of spaghetti, i.e. twisted and tangled.

Now, there is a whole theory of pasta and code. Spaghetti code is at the bottom. Next comes lasagna code. Lasagna code is made in layers, which is nice, but each layer is quite large and to change the things below you may have to move all the layers above, and you have to follow a very strict hierarchy, which sometimes make it impossible for one layer to talk to another one that is not immediately above or below.

Lasagna trumps Monday.

Even better is ravioli code. It comes in small pieces easy to chew, it’s easy to move parts of it around.

My personal favorite is cannelloni code. It is even better than ravioli code, because it’s neatly organized, but still flexible. It’s very easy to subdivide if some part gets too big, and you can change parts without touching anything else. The filling is hidden and you only see the interface :)

Source: http://www.flickr.com/photos/osakajon/22373345/

  1. corollarium posted this