Card 08/ 08

RecapDifficulty: Intermediate1 min

Recap: Reading UML Class Diagrams

Marks inside the box, six arrows between them, and a sequence diagram for order.

A UML class diagram is the usual way a design pattern is drawn, and a short set of marks covers everything patterns use.

  • Inside a box. + public, - private, # protected, ~ package. Italics mean abstract and underline means static. <<interface>> labels an interface.
  • Triangles mean "is a kind of". A solid line is inheritance from a class; a dashed line is realisation of an interface.
  • Diamonds sit on the whole. Hollow is aggregation, where parts come from outside and can outlive the whole. Filled is composition, where the whole creates its parts.
  • Open arrows mean "knows" or "uses". Solid is association, kept in a field. Dashed is dependency, a parameter or a local variable used for one call.
  • Reading order. Abstractions first, then what implements them, then the class that uses them, then the arrows, then ask what can be added without editing a box.
  • Sequence diagrams show order. Lifelines run down the page, solid arrows are calls, dashed arrows are returns, and lower means later.