Part 7 of 7 · 2 min read
Exercises
Easy
Easy 1: Draw a box (20 minutes)
Draw the class box for Room and TimeSlot in the style of section 1.
Done when: two boxes with fields and one method each.
Hint
Put only fields that matter to the story.
Easy 2: Name the link (20 minutes)
Name the link in each case: a car and its engine, a car and a vehicle, a team and its players, a service and a logger it uses once.
Done when: four answers with a reason.
Hint
Use the deletion test for whole and part.
Easy 3: Read a diagram (20 minutes)
Read the section 3 sketch aloud in four sentences, as if explaining it to a colleague.
Done when: four sentences.
Hint
Start with the service, then the booking, then the room.
Medium
Medium 1: Class diagram for a library (30 minutes)
Draw a class diagram for members, books, copies and loans, with multiplicities on every line.
Done when: a diagram with at least five classes and numbers on each link.
Hint
A book can have many copies, and a copy can have many loans over time.
Medium 2: Sequence for cancel (30 minutes)
Draw the sequence diagram for cancel(bookingId), including the case where the id is not found.
Done when: a diagram with a success path and a failure path.
Hint
The failure path ends in an error arrow.
Medium 3: Match code to diagram (30 minutes)
Read the BookingService code in module 4. Check that each arrow in your sequence diagram has a method.
Done when: a list of arrows and the method each calls.
Hint
If an arrow has no method, the design is missing one.
Hard
Hard 1: Redraw after a change (45 minutes)
Add "bookings need approval by a manager" to the room system. Redraw the class and sequence diagrams.
Done when: two new diagrams and a list of what changed.
Hint
Approval adds a status and a new actor.
Hard 2: Explain composition (45 minutes)
Find two cases in a food delivery system where composition is right and two where aggregation is right. Explain with the deletion test.
Done when: four cases with a reason each.
Hint
Ask whether the part makes sense after the whole is gone.
Hard 3: Diagram review (50 minutes)
Take a diagram from any open source project. List what it shows well and three things you would drop for an interview board.
Done when: a short review with the three drops.
Hint
Think about fields and methods that do not drive the talk.