Finding entities and owners
medium 35 minA spec is full of nouns, and most of them are not classes.
Video lesson · Chapter 1 of 6
Make a prediction
See it run
Which noun becomes an object, who may change what, and what goes wrong with two owners.
Operations
The audition
Each noun of the spec gets one verdict and one reason.
Step 1 of 8
Dog and volunteer
| Why | Verdict | |
|---|---|---|
| dog | followed over time | entity |
| volunteer | followed over time | entity |
| walk | ||
| time slot | ||
| level | ||
| phone | ||
| leash | ||
| nervous dog | ||
| (not named) |
We tell two of them apart and follow them. Entities.
Step 1: Dog and volunteer
followed over time? entityguards a rule? ownerfacts travel together? valuelink with facts? class for the linkfixed words? enumonly calls us? no classin no sentence? out of scope- When
- First two minutes
- You leave with
- A short cast list
Say the rejections aloud. They show judgement, boxes do not.
In the real world
The same finding entities and owners doing real jobs. Pick one and step through it.
The noun book is two things, and the verb lend is a third.
Step 1 of 5
A title
People search for a title and reserve a title.
Step 1: A title
Common mistakes
The bugs interviewers watch for, with the fix beside each.
A box for every noun
majorThe round is spent on classes with one field and no method.
Wrongclass Leash: ...class Phone: ...class Day: ...Right# leash: in no sentence. phone: calls us. day: a field of SlotSubclasses for one value
majorA dog that calms down cannot change its class.
Wrongclass NervousDog(Dog): ...Rightdog.needs = Level.EASYA list on both sides
criticalCancel forgets one of them, and a ghost stays.
Wrongdog.walks.append(walk)volunteer.walks.append(walk)Rightrota._walks[walk.id] = walk # the only placeThe missing owner
criticalA rule about all walks cannot be checked by one dog.
Wrongclass Dog: def book(self, volunteer, slot): ...Rightclass WalkRota: def book(self, dog, volunteer, slot): ...A value that changes
majorThe walk moves after it was checked, around the owner.
Wrongwalk.slot.start = 600Rightrota.cancel(walk.id)rota.book(walk.dog, walk.volunteer, Slot(1, 600, 630))
Interview tips
Reject aloud
- Half a sentence each
- Say what would bring it back
- A short cast list is a good one
Ask who can see it
- List what a rule needs
- Smallest object that sees all
- None? Add an owner
One truth
- Derive before you store
- Check cancel and failure
- Values are frozen
Name by content
- Rota, pool, deck, game
- Not manager, handler, helper
- No name means several jobs