Spaghetti Code

Code Structure


description

Alignment

Good programmers will always align their code blocks to make sure other people can visually understand which instructions go together. Computers can simply skip any extra space and execute instructions left to right, top to bottom, jumping around as needed. People, however, cannot quickly grasp which order the instructions will execute unless the instructions have proper structure. There are two important rules to follow for alignment:
  • Write each instruction on a new line
  • Each nested code block gets an additional indentation
Nested code blocks are much easier to explain visually, so let's take a look at an example piece of code on the next page.