Three rectangles, two dashed arrows and one hollow triangle are enough to describe an entire design. A pattern diagram is an argument about responsibilities: who holds the data, who makes the decision, and who is allowed to call whom. Read it in that order — symbols, roles, then a single traced request — and the page turns into a plan you can code.
Decode the shapes and arrows first
- A plain rectangle is a class; a box with an italic or dashed name is an interface or abstract class.
- A solid line means one object keeps a reference to another over time.
- A hollow triangle points at the parent in an inheritance relationship.
- A filled diamond marks composition: the part cannot outlive the whole.
- A dashed arrow marks a temporary dependency, such as a method parameter or a return value.
Notation is not decoration. A diagram drawn with dashed lines where solid ones belong is describing a different design than the one in the code.
Name each participant and its single job
Pattern diagrams label roles rather than your classes: Subject and Observer, Component and Decorator. Cover the names and describe each job in your own words. In an Observer diagram, one object keeps a list of listeners and notifies them; the listeners only react. If you cannot state a box’s job in one sentence, the diagram is telling you a class is overloaded.
Follow one action through the boxes
Pick a trigger — a button press, a price change, a new file — and trace it with your finger. Which box receives it, which box decides, and which box is told last? The order of the arrows is the call sequence, and it usually exposes a dependency the pattern exists to prevent.
Then check the direction of every dependency. Arrows pointing both ways are a warning. Well-drawn patterns aim dependencies at abstractions, so a high-level class never names a concrete one. If your trace runs straight from a user interface class into a database class, the pattern is decorative rather than structural.
Translate the diagram into a skeleton
Write the interfaces first, then one empty implementation, then the wiring. Compile after each step. A skeleton that compiles proves you read the arrows correctly; a class you cannot construct as drawn means you missed an argument or a lifetime.
Keep the diagram next to the code while you do this, and rename your own classes to match the roles once the skeleton works. The names are the cheapest part of the design to change.
Redraw the diagram from memory the next day, without looking, and compare the two versions. The parts you forget are the parts you did not understand, and they are exactly where the code will confuse you later.