Spaghetti, Ravioli, or Lasagna Code?

In a comment on another blog site I had written:

Poor programmers create spaghetti code.

Average/Good/Agile programmers create “ravioli” code… Thousands of little objects.

Architects (especially ones that plan more over longer time frames) create the ideal: Lasagna code, which is a layered architecture.

Choose your pasta wisely :)

A few people had wanted me to blog about it so they could link to it.

I just wanted to expand on the ravioli aspect because different people have different feelings about what ravioli code is.

To some people  — ravioli code — is encapsulated spaghetti. Eg, it’s spaghetti on the inside but it looks like an object on the outside. I would call this “spaghetti stuffed ravioli”.

I feel ravioli code is the “spaghetti like interaction” between the various ravioli objects…

Eg, from the outside, it’s hard to tell which Ravioli is stuffed with lobster, which one with cheese, etc.

Jordan

Further reading: http://en.wikipedia.org/wiki/Spaghetti_code goes into all the code models listed above not just spaghetti.

About these ads

About Jordan Bortz

C#, WPF, Android, Architect, Developer, Consultant, Project Manager available for remote/telecommute assignments
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

2 Responses to Spaghetti, Ravioli, or Lasagna Code?

  1. Joe says:

    While cute, my experience is that “architects” start with so-called “lasagna code”, only to find out that the layers are too encapsulated and completely collapse with subsequent versions due to unanticipated requirements. Ironically, this leads to more spaghetti code than if they had been less rigid and wedded to encapsulation perfection at the start.

    I do try to write layered code, with a series of solid libraries underneath, but within those layers, it’s usually a different story all together. especially as the deadline nears.

    • Jordan says:

      Thanks for sharing your experience.

      I don’t believe, that, necessarily, architects start with a lasagna model, except for those who know that it is necessary.

      For instance, people could start with a bunch of random calls to a database, and then, realize, hey, you know, we really need a DAL (Data Access Layer) to handle this.

      Of course a more sophisticated architect might start with a DAL approach in the first place.

      So I’m not sure what your objection is.

      If you’re saying one shouldn’t layer unknown functionality until the raviolis gravitate that way, I might agree with that.

      Half-baked lasagna probably isn’t that tasty…

      I’m sure it is possible to create ill conceived lasagnas, but as with all things, there is no substitute for skill, experience, and judgement.

      Without that neither a chef or programmer can create a good lasagna.

      Jordan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s