Spaghetti Code

Code Structure


description

Nested Code Blocks

The picture on the left depicts a very small sample of code with three blocks of code. In this particular language, curly braces determine code blocks. Notice an opening curly brace at the end of each line that starts a new code block. Every line after that curly brace gets indented (shown by '|') until that code block ends. And every time a new code block begins within a code block, you must indent again. Following this method, you can trace the start of a code block straight down to its closing tag.
Instructions nested within 1 code block get 1 indentation.
Instructions nested within 2 code blocks get 2 indentations.
etc.
But this code sample looks cramped. Programmers can still tell which instructions go to what code block, but we can improve it with spacing.