Lasagna code, ravioli code

Sun, 2009-03-22 12:22 by admin · Forum/category:

After the erstwhile "spaghetti code", brought about by abusing the GOTO command, Java and its descendants brought us "lasagna code" and "ravioli code". We now have code that is split up into an excessive number of abstraction layers, reminiscent of a lasagna, or into swarms of little objects with very little meat in them, like ravioli, whose interrelationship is almost impossible to find out and understand.

A sure sign of ravioli code is that programmers begin to use a debugger to find out what code is actually being executed and in which sequence, because that is the only way to find out.

Contrary to Italian cooking, you can have both at the same time in a computer program. Here is a quote, taken from

The problem is that it [Ravioli Code] tends to lead to functions (methods, etc.) without true coherence, and it often leaves the code to implement even something fairly simple scattered over a very large number of functions. Anyone having to maintain the code has to understand how all the calls between all the bits work, recreating almost all the badness of Spaghetti Code except with function calls instead of GOTO. It is far better to ensure that each function has a strong consistent description … rather than splitting it up into smaller pieces (”stage 1 of preparing to frobnicate the foo part of the foobar”, etc.) with less coherence. The principal reason why this is better is precisely that it makes the code easier overall to understand.

People who deliberately split code up into ravioli, and especially those who advocate that others do so, are “dangerous idiots” precisely because they’ve lost sight of the fundamental need for comprehensibility …


Related information