UML class diagrams 00:00:00 Make a prediction You will validate a class diagram by walking a concrete object example through its multiplicities, ownership and dependency arrows. One order contains two lines. The diagram says one to one between order and line. Which is wrong: the order or the picture? If two lines are allowed by the agreed requirements, the picture is wrong. One order can own multiple lines. Test diagrams with actual counts before debating arrow styles. 00:00:34 Asha, Lee, Max and the pattern sheet A tailor's pattern sheet marks which pieces are sewn together and how many copies are needed. Cutting just one sleeve because the drawing shows one silhouette gives the wrong garment. A class diagram is likewise a plan for possible object instances. Multiplicity constrains counts; composition describes ownership. Neither is a decoration you can infer from where boxes happen to sit. UML is the Unified Modeling Language: a set of agreed drawings for software. The class diagram is the most used of them. It shows the static structure: which classes exist, what each one knows and does, and which of them know each other. A paragraph can be read in two ways, and a page of code takes long to read. A picture with agreed symbols is read in seconds, and two people who read it see the same thing. 00:01:26 Draw an order and its lines One customer may place many orders. An order belongs to one customer in this model. Write those multiplicities on the association. The order owns its line items. A line without an order has no meaning here, so mark the whole end of that relationship on the order. Trace one order with two items. If the picture says each order can have only one line, the sample exposes the error immediately. Draw an order with two lines, then cancel just the second line. Does anything imply that the second line can still be attached to a different order? Show the intended lifetime and multiplicity explicitly. The reader should be able to tell which links can change independently. 00:02:10 Draw a dependency with a reason Checkout receives a payment gateway to charge an order. An implementation can realize the gateway interface while checkout depends on that interface. A passing reference used during one operation does not automatically mean that checkout owns the provider's lifetime. Draw a test gateway implementing the same interface as the production gateway. The orchestrator points at the contract; both concrete types point back to it as implementations. If the orchestrator also stores a concrete production gateway, substituting the test double requires another edit. A transient payment gateway argument is a dependency; it does not automatically mean checkout destroys the bank adapter when checkout is discarded. Use a sequence diagram as a companion when the important question concerns call order rather than structural ownership. In a UML class diagram, an open triangle points to a parent type. A filled diamond marks the owning end of a composition, and an open diamond represents shared aggregation. Multiplicities sit near the ends they describe. A text diagramming tool such as Mermaid can store these relationships alongside code, so a changed ownership rule can be reviewed in the same change. 00:03:28 Try an interview follow-up Two teams argue whether a line is aggregation or association. How do you end it? Ask what would differ: who creates the part, who deletes it, may two wholes share it, is there a cascade. If the answers are the same, the notation does not matter, and I draw a plain line with a verb. If they differ, write the answers down as rules, because those go into the schema. Draw a library member and a loan. What does the diagram say about a member with zero loans and a loan with two borrowers? Mark the multiplicities your requirements allow. Then trace a returned book. The loan record may remain in history even though it no longer appears among current loans. 00:04:18 What to take with you Box: name, what it knows, what it does. Marks: plus, minus, hash, tilde. Lines: solid is a lasting link, dashed is a promise or a short use. Triangles point at the more general type. Diamonds sit at the whole. Draw for one question. Put the three to six classes that answer it on the board, write how many at the line ends, and say the sentence that each line stands for. If you cannot say it, the line is wrong.