Each outcome is backed by the checks that test it. Solid means every check was right first time; with hints means you got there with a nudge; worth a revisit means an answer was revealed or is still wrong.
1
Say what a design pattern is, and pick Strategy, Factory or Observer for a problem described in words.
Not yet
2
Write a Strategy: a class that holds a swappable object behind an interface, calls its one method, and can swap it while the program runs.
Not yet
3
Write a Factory: one method that turns a name into the right object, and reports a name it does not know.
Not yet
4
Write an Observer: a class that keeps a list of subscribers, adds and removes them, and calls update on each when something happens.
Not yet
5
Spot the three patterns in library code you already use, and say when a plain function, a dictionary or an if is enough.
Not yet
Your cheat sheet
What each lesson leaves you able to do, in one place. Lessons you have not finished are dimmed, not hidden.
Say what a design pattern is: a well-known shape of classes for a problem that keeps coming back, with a name.
Say why the name helps: one word tells another programmer which classes and arrows you mean.
Say that a pattern is a shape you fill in with your own names, not code you copy from a library.
Match the three first patterns to their problems: Strategy swaps how something is done, Factory decides what to make, Observer tells everyone who asked.
Spot the problem Strategy solves: one function with a branch for each way of doing the same job.
Put each way into its own class with the same method, behind one interface (RouteStrategy and minutes).
Write a class that holds one strategy in a field, calls its method, and lets you swap it with a setter.
Read the Strategy class diagram (a line with a hollow diamond from Navigator to the interface) and its sequence diagram (plan, then minutes, then the answers back).
Add a new way as a new class, with no edit to the navigator.
Say that the key you pass to a sort (Python's key, Java's Comparator) is a strategy.
Say that List.of and Integer.valueOf in Java, and open in Python, are factories: the call decides how to make the object.
Say that click listeners in window libraries are Observer: the button keeps a list and calls each one.
Write a one-method strategy as a plain function in Python or a lambda in Java.
Say when not to use a pattern: an if over two fixed cases, a dictionary (a map in Java) from name to class with no other work in between, or an object made in one place does not need one.
Name the pattern a shipping problem needs, predict a strategy and an observer, complete the line that adds a watcher, and decide when a factory is not worth it.