Object & graphSample
UML class diagram
Object-based modelling: classes with attributes and behaviour, connected by inheritance, composition and other typed relationships.
Try this
- 01Click CardPayment: the panel shows everything it “is”, walking up through the interface.
- 02Highlight Composition, then Aggregation: compare the filled and hollow diamonds and what happens to the part when the whole is deleted.
- 03Switch compartments to Names only: the structure of the domain reads more clearly without the detail.
Notation
- Class
- Three compartments: name, attributes, operations. + is public, - is private.
- Abstract class
- Name in italics. Never instantiated directly, only through its subclasses.
- «interface»
- A contract of operations with no data. Classes realise it.
- Inheritance (hollow triangle)
- “Is a”. The subclass gets everything the parent has.
- Realisation (dashed, hollow triangle)
- “Implements”. The class fulfils the interface’s contract.
- Composition (filled diamond)
- “Owns”. The part cannot outlive the whole: delete the order, its lines go too.
- Aggregation (hollow diamond)
- “Has”. The part can exist on its own: a product survives its category.
- Dependency (dashed arrow)
- “Uses”. A temporary or parameter-level link.
- Multiplicity
- 1, 0..1, 0..*, 1..* at each end say how many objects take part.
Use it when
- Designing application domain models and APIs
- Explaining inheritance and ownership rules to developers
- Mapping objects to tables (ORMs)
Avoid it when
- Designing the physical database (use an ERD)
- Audiences who are not software engineers