Program design

Patterns and mad libs

Tasks that look different on the surface may be the same underneath. Look under the surface to find a program's structure. You can use that structure for hundreds of tasks, making you a more valuable programmer.

A pattern is a common way of doing things. Many programs use the same patterns. IPO (input, processing, output) is a common pattern.

When I write a program, I start with comments showing the program's structure.

A structure diagram shows the code chunks that make up a program, and the variables linking them together.

Tip calculator

Let's make a simple calculator to work out restaurant tips.