Object diagram
Where a class diagram shows types, an object diagram shows actual instances with actual values. It is a snapshot, and it is unusually good at explaining a confusing structure by example.
Use it when a class diagram has left people unsure what the data actually looks like.
#When to draw one
Explaining a model by example rather than in the abstract.
Documenting a specific test scenario or fixture.
Teaching, where a concrete instance beats a general rule.
#What is on the diagram
Element | Meaning |
|---|---|
Object | name : Type, underlined |
Attribute values | Actual values, not types |
Link | A line between objects, an instance of an association |
#A worked example
One order, with its real values:
The source, which you can paste into a new diagram and edit:
#A few things that catch people out
Use real, plausible values. Foo and bar defeat the purpose of an object diagram.
It is a snapshot at one instant. Say which instant if it matters.
Pair it with the class diagram rather than replacing it.
#Related
Four types cover most of it.
