Whiteboarding and Pseudocoding

Learning Goals

  • Understand the relationship between problem-solving, programming, and algorithmic thinking
  • Identify and implement different strategies for solving problems
  • Identify common roadblocks to effective problem-solving

Warm Up

  • When you are presented with a problem, how do you solve it?
  • In your journal, draw out the process of how you make toast. You must start with a clean sheet of paper and you are not allowed to write/use any words.

Problem Solving

When you are presented with a problem… whether it is a complex mathematical problem or a broken printer, how do you solve it? Generally speaking, the first step in finding a solution to a problem is to be sure that you have clearly identified the problem itself. To solve problems, we can utilize the UPS strategy:

  • Understand: Read the problem. Restate the problem by writing it down in your own words. What do you know? What do you not know?
  • Plan: What problem strategy will you try? You might also draw a picture/representation of how you plan to approach the problem
  • Solve: Use your plan to implement your solution

Possible Problem Solving Strategies

Method Description Example
Trial and Error Continue trying different solutions until problem is solved Restarting phone, turning off WiFi, turning off bluetooth in order to determine why your phone is malfunctioning
Heuristic General problem-solving framework Working backwards, breaking a task into steps
Algorithm Step-by-step problem solving formula Instruction manual for installing new software on your computer

Journal/Reflection

Think about how you currently solve problems when you are programming. Has that changed since you were in Mod 1? What are some of the possible pros and cons of the methods listed above?

Whiteboarding

In the context of building out programs, whiteboarding is a useful tool to ulitize in solving complex problems. If we rush into coding out the solution immediately, we completely skip over the Planning part of the process… and its likely that we don’t fully Understand the problem at hand.

In the context of interviewing for a job, being able to whiteboard is important because it shows you can think through/discuss a problem without having to actually code it first - which can be a difficult skill to learn.

Things to remember

  • Ask for feedback
  • Talk as you write
  • Pay attention to the amount of space you have to write
  • DON’T WIPE THE WHITEBOARD WITH YOUR HAND WHEN YOU ERASE THINGS
  • High level vs low level
  • Develop a shorthand for writing code:
if (foo === 'bar') {
  this.changeFoo('baz')
} else if (foo === 'baz') {
  this.changeFoo('bar');
} else {
  this.changeFoo('caw caw');
}

Could be written as shorthand:

foo = baz?
  changeFoo(bar)
foo = bar?
  changeFoo(baz)
else 
  changeFoo(caw caw)

Turn and Talk

With a partner, draw out the process of making a sunbutter and jelly sandwich with blank post-its and the table space in front of you as your “whiteboard.” Do not write words to describe this process!

Pseudocoding

Pseudocode is an artificial and informal language that helps programmers develop algorithms to solve problems. A key thing to remember is that psuedocode is not code. It is a way to force yourself to slow down and think about how to solve problems at a high-level, using natural language.

Pseudocode:

  • gives you a fallback
  • gives people 👀 the chance to intervene
  • demonstrates your logic
  • takes syntax errors out of the equation

Basic Structure for Pseudocoding

Sequences: Sequences are the most straightforward part of structuring pseudocode. At the most basic level, a sequence is made up of commands or steps that must be followed. Any commands in a sequence are generally written as a list.

Here’s an IRL example of a sequence for feeding my dogs:

// Pick up dog bowls from the floor
// Bring bowls to pantry
// Open up big dog food bag
// Fill big bowl
// Open up small dog food bag
// Fill small bowl
// Call dogs by name
// Place both bowls on the floor

Choices: Choices give us the option to take different paths based on certain conditions. You may find that you have just one path based on a condition, two paths, or multiple paths.

Here’s another IRL example of how I may choose a certain path (based on the weather) when dressing myself in the morning:

// Check the weather forecast
// If snow is expected, put on boots
// Otherwise, put on flip flops

Iterations: Iterations allow us to repeat steps until a certain condition is met. They always begin with a choice. Here’s another IRL example of preheating my oven:

// While the oven is not 350 degrees, wait

Which could also be written like this:

// Until the oven is 350 degrees, wait

Group Exercise:

In your group, solve the following IRL task in psuedocode: Break out the recipe for making grilled cheese into discrete steps. Note: A cheese sandwich is a basic sandwich generally made with one or more varieties of cheese on any sort of bread. A grilled cheese sandwich is made by grilling the sandwich with butter or toasting it.

Some possible pitfalls to problem solving

  • Mental set - Persist in approaching a problem in a way that has worked in the past but is clearly not working now
  • Anchoring bias - Tendency to focus on one particular piece of information when making decisions or problem-solving
  • Availability bias - Decision is based upon either an available precedent or an example that may be faulty

Summary

In your journal, answer the following:

  • What kind of pitfalls/biases do you recognize in your own problem solving process?
  • How can you use your awareness of this to improve your problem-solving skills during your time as a developer?
  • Why are problem-solving strategies important?

Lesson Search Results

Showing top 10 results