Skip to content

Instantly share code, notes, and snippets.

@jnewman12
Created December 6, 2016 05:00
Show Gist options
  • Save jnewman12/2b63bd7651a907513ebf66a4cf8e0036 to your computer and use it in GitHub Desktop.
Save jnewman12/2b63bd7651a907513ebf66a4cf8e0036 to your computer and use it in GitHub Desktop.
Slides on JS Pseudo-coding

Pseudocode!


SWBAT

  • Describe what pseudocode is
  • Explain why pseudocode is a useful part of the development process
  • Use pseudocode to break down code challenges

Intro

  • 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.

Pseudocode Examples

  • 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.

Starting the Game

  1. Set turn counter to 0
  2. Clear game board
  3. Set current player to player one
  4. 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.

Taking Turns

  • 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.

Activity

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

Great, I've written some pseudocode. What now?

  • Now you convert it into actual code! Let's do a few examples together.

Code Challenge

  • 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.

Conclusion

  • 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?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment