Design Computation

## Pseudocode

Pseudocode is a technique of using English to describe computational processes. Pseudocode itself has many forms, and the pseudocode itself doesn’t have much use in a programming environment, but the act of translating between code and pseudocode and vice versa is an important skill to learn.

When breaking down an abstract design problem, one can use pseudocode as a means of communicating to others how to translate the abstract problem into an appropriate computational implementation.

### Examples of Pseudocode in Everyday Life

Pseudocode is really just a set of instructions. It is especially suited towards imperative types of computation, in which we have data that we change over time.

Recipes for cooking are an imperative type of process. In computation, we might call this a procedure, a series of instructions that are executed from beginning to end without prejudice or alteration.

### The Bouncing Ball

1. Initialize the ball’s variables randomly.
2. Clear the sketch window.
3. Draw the ball.
4. Increment the ball’s x and y positions with the speed.
5. Change the vertical speed for gravity.
6. Check to see if the ball goes outside the boundaries.
7. If the ball goes outside the boundary, bounce the ball by changing the direction.
8. Check to see if the ball hits the paddle.
9. If the ball hits the paddle, bounce the ball by changing the vertical direction to negative.
10. Repeat.

### Pseudocode is English

Pseudo-code are a program’s instructions written in plain English.

Writing pseudocode is important when things get complex, or when relating a procedure or algorithm to others who may use programming languages other than your own.

It is primarily a method of collecting your thoughts, of seeing a set of instructions plainly, without the burden of syntax and programming languages. With this technique, you can determine how to structure your code, that is, what functions to write, where to set up loops, etc.

It’s also useful for seeing if your instructions really make sense and solve the problem you think they solve.