Spaghetti Code is Delicious
Nov. 16, 2025
You're coding and you finish a small but useful program... which turns out to be VERY useful. Which leads you to expand and improve its functionality over time. And as you continue to expand that code... you unexpectedly arrive in a place where it's difficult to work on it. You can't figure out why new bugs are popping up in code that used to work. It's difficult to think about how to add a new feature to the program -- so you carve out a new space and hastily wire it up into the old code! Now THAT rats nest of digital wires starts to haunt the code whenever you have to update it. Spaghetti.
And I'm here to tell you to eat that spaghetti. It's delicious.
Mount Spaghetti, a destination every programmer is well familiar with and which all of us must visit on our career journey! It's an unsightly place, but one that inexperienced developers really can't avoid. But it's also a base camp of sorts for skill development.
And which skills? Code refactoring, which requires the ability recognize, extract and apply coding patterns.
So yeah, eat your spaghetti because it'll help you learn valuable programming techniques that you'll need to avoid it in the future. To start, focus on solving the problems in your code and head over to YouTube to see a brief demonstration of the following steps.
And I'm here to tell you to eat that spaghetti. It's delicious.
Mount Spaghetti, a destination every programmer is well familiar with and which all of us must visit on our career journey! It's an unsightly place, but one that inexperienced developers really can't avoid. But it's also a base camp of sorts for skill development.
And which skills? Code refactoring, which requires the ability recognize, extract and apply coding patterns.
So yeah, eat your spaghetti because it'll help you learn valuable programming techniques that you'll need to avoid it in the future. To start, focus on solving the problems in your code and head over to YouTube to see a brief demonstration of the following steps.
Step 1: Inputs and Outputs
First, identify the data in your program and separate it into 2 categories: inputs and outputs. This can help you identify useful data structures, which will be important to organizing your data. Further, distinguish the configuration data from runtime data.
Step 2: Visualize
Next, create a visual diagram or drawing of the program flow. If you’ve never done this before, it can feel a bit slippery. But frankly, if you’re not in the habit of visualizing the problem, it’s one reason you have spaghetti code in the first place. I tell my apprentices all the time: if you can’t explain your program in your first language (e.g.: English) or draw me a picture of what it does, then you don’t understand the program.
Step 2: Visualize
Next, create a visual diagram or drawing of the program flow. If you’ve never done this before, it can feel a bit slippery. But frankly, if you’re not in the habit of visualizing the problem, it’s one reason you have spaghetti code in the first place. I tell my apprentices all the time: if you can’t explain your program in your first language (e.g.: English) or draw me a picture of what it does, then you don’t understand the program.
It’s impossible to overstate the importance of this step – to untangle something is to understand where it begins and where it ends. You’re trying to identify structures, behaviors and data in order to place them strategically.
Think of this as kinda like making a map. It marks places, important landmarks, and displays topological information. A good map may even tell you why you want to visit certain places. It allows the user to create paths to where they want to go -- and to avoid all the places they don’t want to go.
Step 3: Implementation
Ideally, you started down this path with a working program. Your goal is to ensure it continues to work as you refactor it. This means going in with a scalpel, not a chainsaw. You can add new code, but you don't want to remove the old code until the new code works -- or you'd better have a damn good reason to do otherwise.
Name the different states, processes and behaviors you’ve identified. With your whiteboard nearby, head back to your keyboard, turn on the debugger and gradually implement the plan 1 line of code at a time. Revisit the whiteboard as you learn new things during implementation, clarifying your map and refining your process. This step may take a while. But see it through -- do it until its done.
Think of this as kinda like making a map. It marks places, important landmarks, and displays topological information. A good map may even tell you why you want to visit certain places. It allows the user to create paths to where they want to go -- and to avoid all the places they don’t want to go.
Step 3: Implementation
Ideally, you started down this path with a working program. Your goal is to ensure it continues to work as you refactor it. This means going in with a scalpel, not a chainsaw. You can add new code, but you don't want to remove the old code until the new code works -- or you'd better have a damn good reason to do otherwise.
Name the different states, processes and behaviors you’ve identified. With your whiteboard nearby, head back to your keyboard, turn on the debugger and gradually implement the plan 1 line of code at a time. Revisit the whiteboard as you learn new things during implementation, clarifying your map and refining your process. This step may take a while. But see it through -- do it until its done.
Describing the process like this in a video or article is kind of a challenge in itself, because programming isn't really a neat and tidy process. It's quite messy and things never quite go the way you want. So you're constantly experimenting, learning and applying new ideas, adjusting your plan as you go. There's a lot of back and forth: you design a system on a whiteboard, try to build it then head back to the board after learning where your ideas fall short.
However, in the end there should be a lot less spaghetti on your plate when you’re done. Your program should still work and you should find it less intimidating to revisit for updates and new features. Refactoring is always worth the effort and the trick going forward is to do it a little more often. Programming is an iterative process and truthfully, you can iterate as long as you want. So it's important to set boundaries -- a topic for another day.
However, in the end there should be a lot less spaghetti on your plate when you’re done. Your program should still work and you should find it less intimidating to revisit for updates and new features. Refactoring is always worth the effort and the trick going forward is to do it a little more often. Programming is an iterative process and truthfully, you can iterate as long as you want. So it's important to set boundaries -- a topic for another day.