Jonathan Bennett

More Spaghetti, Less Spaghetti Code

There are few meals I enjoy more than pasta. I would eat it basically in basically any form 8 days a week if given the chance. That said, I loath code that resembles a plate of spaghetti.

Spaghetti code is code that is needlessly complex due to its structure. It is the digital equivalent of a Rube Goldberg machine1.

Spaghetti code is natural and the default for most organizations. This is not the result of a bad programmer. Spaghetti happens when the normal programming process is cut short:

  1. Define the problem: what is the intended outcome?
  2. Do anything that solves the problem, it doesn’t matter if it is good or clean.
  3. Test the solution, preferably automatically, to make sure the complete problem is solved and nothing is accidentally broken.
  4. Clean up the solution until it is suitably beautiful.

To increase speed, step #4 and event #3 are sometimes skipped. This can have short-term benefits, but falls apart almost immediately, largely due to an infestation of messy code. For instance, I was recently working on a code base that had a 150 line invoice computation function which did some work and saved it as temp_var. This was used throughout the rest of the function. Do you think you’ll keep straight what temp_var represents when you see it 100 lines later? Would you be just as confident if saw another variable named temp_var1? Would you still be confident if there was a temp_1 too?

Improving this code is possible! Working Effectively with Legacy Code by Michael C Feathers and Refactoring: Improving the Design of Existing Code by Martin Fowler are great resources for working with existing spaghetti code and turning it into something much easier to work with.

Save spaghetti for your dinner plate. It’s way better than in your code!

If your startup is struggling with code that looks a little too pasta-y for comfort book a free call today. I’ll help you get unstuck and begin moving forward.


  1. I love a good Rube Goldberg machine. This one is pretty fun for instance