From failure modes to checks
Why it matters A pre-mortem asks for stories. A failure-mode list is the same idea done systematically: walk through the kinds of thing that break systems, and ask of each one, how would it break this one?
An office books meeting rooms. Times are minutes since midnight, and a booking covers [start, end): it includes its start minute but not its end, so a meeting ending at 10:00 and one starting at 10:00 do not clash.
r = make()
b = r.book("oak", 540, 600) # an id, or None if refused
r.cancel(b) # True
r.bookings("oak") # [] sorted (start, end) pairsA failure-mode checklist
- Boundaries: what happens exactly at the edge (equal times, the last slot)?
- Containment: one thing entirely inside another.
- Undo: does cancelling really put things back?
- Bad input: empty, backwards, missing.
- Isolation: does one customer, room or tenant leak into another?
- Repeats: the same action twice.
A sparring prompt: "Here is my booking API. For each failure mode on this list, give one input that might break it." Judge the answers, then write the checks yourself.
Set failure_modes to a list of at least 4 failure modes you will check (one line each). Then write check_rooms(make): make() returns a fresh booking system; raise if it breaks a rule. The rules: book(room, start, end) returns a booking id, or None if refused; a booking needs start < end; bookings in the same room may not overlap, but back-to-back is fine; rooms are independent; cancel(id) returns True and frees the slot, and returns False for an id that is unknown or already cancelled; bookings(room) is the sorted list of live (start, end) pairs. Pass bar: pass the correct system and catch at least 4 of the 6 faulty ones.
Spotted a problem in this lesson? Report it · Ask about this lesson
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.