The Spaghetti Syndicate
"A family-run logistics company. Four generations of code. Nobody dared touch the 'sacred functions.'"
The Arrival
Setting the Scene
Naples teaches you something about persistence. The city has been conquered, burned, rebuilt, and conquered again. Yet it endures. The same families run the same businesses from the same streets, generation after generation.
The Caruso family has been moving freight across southern Italy since 1923. Started with mules. Now it's trucks and container ships. But the system that tracks it all? That started in 1997.
I entered through a web form—an old contact page that still used the original PHP include vulnerability. Twenty-seven years and nobody patched it. In Naples, you don't fix what still works.
The server room was a converted wine cellar. I'm not kidding. Actual wine cellar. The servers sat where barrels once aged. There was still a faint smell of oak and old Aglianico.
The Discovery
What I Found in the Dark
The codebase was PHP 4. Not maintained PHP 4. Original PHP 4. From 1998. Running in production. Processing 400 shipments a day.
But here's what made it special: the comments were in four languages. Italian from the grandfather who started it. English from the American consultant they hired in 2005. German from an intern in 2010. And something that looked like Neapolitan dialect from someone who clearly didn't trust any of them.
There was a function called 'la_funzione_sacra'—the sacred function. 847 lines of spaghetti that calculated shipping costs. A comment at the top, dated 2003, said: 'Nonno wrote this. Do not change. We tried in 2008. Three trucks went to Palermo instead of Pisa.'
I traced the bug. It wasn't a bug. It was a feature. The grandfather had built in special pricing for 'friends of the family'—hardcoded customer IDs that got 40% discounts. Some of these 'friends' had been dead for twenty years. Their accounts still got the discount.
The Evidence
Before & After
// la_funzione_sacra - NONNO WROTE THIS
// DO NOT CHANGE - we tried 2008, disaster
function calcola_spedizione($peso, $dest, $cliente) {
global $amici_famiglia;
$prezzo = $peso * 0.50;
if (in_array($cliente, $amici_famiglia)) {
$prezzo = $prezzo * 0.60; // sconto amici
}
// ... 800 more lines ...
return $prezzo;
}/**
* Wrapper for legacy shipping calculation
* Preserves Papa Enzo's original logic
*/
function calculate_shipping(
ShippingRequest $request
): ShippingResponse {
// Validate input
$validated = $this->validator->validate($request);
// Call sacred function (untouched since 2003)
$price = calcola_spedizione(
$validated->weight,
$validated->destination,
$validated->customerId
);
// Log for auditing (never had this before)
$this->auditLog->record($request, $price);
return new ShippingResponse($price);
}The Work
How I Fixed It
I don't believe in breaking things that work. Even sacred things. Especially sacred things.
I refactored around the sacred function. Didn't touch a line of Nonno's code. Just built a clean wrapper that validated inputs, handled errors, and logged everything.
The real problem was memory. The server had 512MB of RAM. In 2024. They were running garbage collection manually—and I mean that literally. Someone logged in every night at midnight and ran a cleanup script.
I optimized what I could. Cached the shipping calculations. Fixed the n+1 queries that loaded every shipment into memory just to count them. Brought the response time from 12 seconds to 200 milliseconds.
And I left Nonno's sacred function exactly as he wrote it. Some code deserves respect.
The Reflection
What It Means
We talk about technical debt like it's always bad. Like every shortcut is a sin. But sometimes, technical debt is just... family history.
The Carusos built something that works. It's ugly, sure. It's old. It violates every principle I know. But it's survived four generations of a family business. How many startups can say that?
Before I left, I found one more comment, buried in a config file. Written in 2001 by the grandfather: 'If you're reading this, the system still works. That means I built it well. —Papa Enzo'
He was right. He built it well. Not clean. Not modern. Not scalable. But well.
The sun was coming up over the bay of Naples as I disconnected. Somewhere in that wine cellar, an old PHP script was waking up for another day of work.
Papa Enzo would be proud.
Every codebase has a story. Every bug has a history. The question is: who's listening?
> END_TRANSMISSION