Problem analyzer
medium 45 minEight questions that turn any prompt into a design skeleton in about six minutes: verbs, container, item, manager, policy, lifecycle, speed and sharing.
Video lesson · Chapter 1 of 6
Make a prediction
See it run
Eight questions, five prompts, and a new one down to running objects.
Operations
Parking lot
Fill the eight lines for: design a parking lot.
Step 1 of 6
Empty sheet
| Answer | Decision | |
|---|---|---|
| Verbs | ||
| Container | ||
| Item | ||
| Manager | ||
| Policy | ||
| Lifecycle | ||
| Speed | ||
| Sharing |
Same eight lines as always.
Step 1: Empty sheet
for question in ["verbs", "container", "item", "manager", "policy", "lifecycle", "speed", "sharing"]: answer = ask(question) decide(answer) # or: not needed- Heavy line
- speed, sharing
- First class
- spots
Say the line before the step.
In the real world
The same problem analyzer doing real jobs. Pick one and step through it.
A substring search reads: design a phone address book.
Step 1 of 3
Look for one
- p
- h
- o
- n
- e
Found, inside phone.
Step 1: Look for one
Common mistakes
The bugs interviewers watch for, with the fix beside each.
Pattern from a word
criticalThe word may be inside another word, or mean something else.
Wrongif "one" in prompt: use("Singleton")Rightif "single" in words(prompt): ask("Would a second one be wrong?")Filling every line
majorInvented managers and phases must be defended.
Wrongclass CacheManagerService: def __init__(self, cache): ...Right# manager: none, the cache is enoughStoring what can be computed
majorIt must be kept in step with every move.
Wrongself.status = "check"Rightdef in_check(self, side): return self.attacked(self.king(side))A phase on the wrong object
majorOne empty slot closes the whole machine.
Wrongmachine.state = SOLD_OUTRightif slot.count == 0: show("SOLD OUT")Rule between items inside an item
criticalA tablet cannot see the other tablets of a reader.
Wrongclass Tablet: def lend(self, reader): ...Rightclass TabletDesk: def lend(self, reader): ...
Interview tips
Aloud
- Question.
- Answer.
- Decision.
Save time
- None is an answer.
- Values are not classes.
- Find the heavy line.
Look back
- Owner for every verb.
- First and last phase.
- Guard for every shared thing.
Do not
- Recite letters.
- Trust keywords.
- Start with nouns.