A shared reference occurs when multiple object instances reference the same referenced object instance. It usually signals that the referenced class needs entity identity and an independent or potentially shared lifecycle, rather than value-type treatment. section 5.1.3 section 9.1
Use lifecycle and reference structure to distinguish shared entities from dependent value types:
- Treat a class as an entity when instances have their own identity, receive references from multiple instances, and can outlive individual references. section 5.1.3
- Treat a class as a value type when one owning instance fully controls its lifecycle and no other instance can reference it. section 5.1.3
- Reclassify a dependent object as an entity when a later association creates shared references, even if its lifecycle remains dependent. section 5.1.3
An address shared by users and shipments
A User may reference an Address as shippingAddress, while a Shipment also references that same Address instance. This makes Address an entity with its own identity instead of an embeddable component. By contrast, billingAddress, homeAddress, and shippingAddress are often modeled as an embeddable component when each address belongs exclusively to one User. section 9.1
Use the entity/value-type diagram to inspect how stereotypes, ownership, identity, and shared references influence persistent-class design. section 5.1.3
