- Describe what pseudocode is
- Explain why pseudocode is a useful part of the development process
- Use pseudocode to break down code challenges
- From wikipedia: Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm.
- It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading.
- What does this mean? Basically, pseudocode is a method you can use to plan out how to code something without worrying about syntax.
- It's like a rough draft or a sketch.
- This weekend you all worked on building Tic Tac Toe games.
- Here are some examples of ways you could use pseudocode to break down the game logic of Tic Tac Toe.
- Set turn counter to 0
- Clear game board
- Set current player to player one
- Prompt player one to start the game
- That just looks like a list. Now let's look at an example that looks a little more like code, but not much.
- When a square is clicked
- If it is X's turn claim the square for X make it O's turn else claim the square for O make it X's turn
- still just plain English, but there are some keywords thrown in (if and else) that give a little clearer picture of what our JavaScript will look like.
In pairs, let's have thirty minutes to pseudocode Tic Tac Toe. Write out how to:
- Start the game
- Take turns
- Determine a winner
- Congratulate the winner before automatically starting a new game
- Reset the board
- Tournament - play to five
- Keep score
- Congratulate the winner before automatically starting a new tournament
- Now you convert it into actual code! Let's do a few examples together.
- Write a JavaScript function that takes a string as an argument. If the string contains only capital letters, log "STOP SCREAMING AT ME!" otherwise, log "Okay."
- Use pseudocode to break the problem down before writing any actual code.
- Let's discuss a few other examples, besides Tic Tac Toe, where pseudocode would be helpful in breaking down a coding task.
- Do you think pseudocode will be useful in your projects? In your post-WDI coding careers? In interviews?