Food-based coding metaphors
Spaghetti code is a term of disparagement in software development, used to describe a code that's tangled and unstructured — much like a plate of spaghetti. This kind of code is difficult to follow, understand, and maintain.
This made me wonder what other food-based metaphors there might be for code.
Lasagne code would naturally mean "layered and structured", the kind of thing to which we all aspire, where each part has a clear and well-defined form and location, and they are bound together in a predictable fashion.
Fusilli code, which has all the problems of spaghetti code, except now each thread is shorter and it's up to you to figure out how they go together. This is how I have come to see "Clean Code":
The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that.
Specifically, aim for less than 10 lines, and "as few arguments as possible, ideally none".
I am not a fan of this. There is no single ideal size for a function, it can be one line or one thousand. In fact, I've seen code which genuinely had a thousand(!) lines inside an if {}
block, and the code was easier to read in that form than it would have been if the if
had been split up this way. Don't get me wrong, that thousand line if {}
block was still really bad code for other reasons, it's just that splitting it up this way would have made it worse, not better, as it would have become ten lines where each was a call to a function that was itself ten lines that were each function calls to a third layer of ten-line functions that, honestly, quite a few of those were themselves also function calls.
And if your functions have no arguments, they must be acting purely by side-effects, which makes it harder to figure out what they do and which other parts of the codebase they influence.
Alphabetti-spaghetti code sounds like a good name for anything involving a RegEx.
[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?
Mystery sausage code would be a good name for neural networks: a mixture of unknown origin whose contents are homogenised to the point of being indeterminable. You're never quite sure what goes into them, you're never sure if they're safe, and if you're not careful about your suppliers you might find you're being fed one even when you were expecting something of higher quality.
Spicy code covers up an incredibly basic rote task with a fancy import
ed extra, akin to how the difference between making Mexican and Indian cuisine can be as little as "which spice mix did I add to my batch of onion, tomato, and peppers, which I then serve with rice?"
Traditional home-cooked organic code has to be FOSS in general. Proponents tell you how much better it is than the factory stuff, or how this gives you control over what you're consuming, but (to the horror of those who love it) most people not only genuinely don't care, they even find this somewhat pretentious.
Coca-coda — just as soda is almost entirely synthetic, not recommended by dietary experts, and yet still one of the most popular drinks on the planet, so too is AI-generated code almost entirely synthetic, disfavoured by experts, and extremely popular.
![](Screenshot 2024-07-13 at 18.35.17.png)
Allotment code is where the consumer is also the creator, and they do it more for fun than anything else — personal projects, like everything on my own GitHub page.
Fast code is where the developer wasn't paid to care, just to shovel out as much as possible as fast as possible for as little money as possible. May involve Coca-coda and Spicy code.
Tags: Coding, Opinion, Programming, software engineers
Categories: Opinion, Professional, Software