Spaghetti Code

noun

say it: “spuh-GET-ee KOHD” /spəˈɡɛti koʊd/

Code whose flow jumps everywhere, so nobody can follow one path through it.

What is spaghetti code?

Spaghetti code is code whose flow is tangled like a plate of spaghetti: flags set in one place and read far away, methods calling back and forth, shared variables changed from anywhere. Nobody can follow one path through it, so every change is a guess. The better answer is to pin down what it does with tests, then untangle it in small steps into named methods with clear inputs and outputs.

In a sentence

  • “Nobody could change the reminders safely, because they were spaghetti code.”

Level: Apprentice · More Software Development terms at this level

Updated