7 Steps For Solving a Problem With Programming
2 Steps
- Get A Task
- Write Working Code



7 Steps
- Solve a small version by hand
- Write down the exact steps you took
- Develop an algorithm
- Check the algorithm by hand
- Translate algorithm to code
- Run test cases
- Debug any failed test cases

Solve A Small
Version By Hand
Solve A Small Version By Hand
- Small instance - 4 or 5 pieces of data
- Make sure the problem is clear
- Make sure you have domain knowledge
Solve returning rank by name

Write Down the
Exact Steps
Write Down the Exact Steps
- Write precise steps
- Stick to the exact instance
- Don't gloss over anything!
Returning Rank By Name
- Find rank for "Emma", "F"
- Set rank to 0
- Open CSV
- Begin checking first row, set rank to 1
- Check first row - is name "Ava"?
- Check first row - is sex "F"?
- If No, move on to second row, set rank to 2
- Check second row - is name "Ava"?
- Check second row - is sex "F"?
- We've got a match, return rank.

Develop
an
Algorithm
Develop an Algorithm
- Finding Repetitive Behavior (loops, iterations)
- Find conditional behavior
- Substitute specific data for variables
- Move from the concrete to an abstract solution!
Returning Rank By Name
- Find rank for name, sex
- Set rank to 0
- Open CSV
- For each row:
- increment rank
- if row name and row sex match name and sex return rank

Check The
Algorithm By Hand
Check The Algorithm By Hand
- Are there any incorrect patterns?
- Were any steps missed?
- Try with a few different outputs
Returning Rank By Name
- What happens if no match?
- What happens if unexpected data types are passed in?
- What happens if CSV is formatted incorrectly?
- What happens if there is a tie between number of names?
Translate Algorithm
To Code
This part we should just know how to do by now.

Run Test Cases
- Execute the Program
- Check answers
Debug Failed Test Cases
- Use the tools of your environment
- Log values
- Use a debugger
Let's Practice!
- Solve a small version by hand
- Write down the exact steps you took
- Develop an algorithm
- Check the algorithm by hand
First 4 Steps
- Given an input of 0 to 10 numeric digits
-
Decode the digits using a telephone alphanumeric keypad map to an English Word
- 364 would be "dog"
- 36449 would be "doggy" or "foggy"
- 0364490 would be "doggy" or "foggy"
- If a word can be decoded, return it.
- If there is more than one solution, return the longest word.
- If there is a tie for longest word, return the first found.
- If there is no word found, return an empty string.
Vanity Telephone Number Guesser Service
- You already have a service available which accepts a string and returns whether or not it is an English Word
- Here is the alphanumeric telephone map:
Assumptions / Tools


7 Steps For Solving a Problem With Programming
By Ryan Moore
7 Steps For Solving a Problem With Programming
A language agnostic methodology for software engineering.
- 541