问题
What are differences between instance and role in terms of UML (class diagram, object diagram, sequence diagram) ?
回答1:
Roles (e.g., in a composite structure diagram) are another representation of properties shown in a class diagram. On the composite structure diagram one can show a particular configuration of which subtype is used for each property. A role name and type is not underlined.
In contrast, an instance specification represents a partial or complete instance. On a class diagram, an instance specification can show values for every property, including links to other instance specifications. An instance specification name and type is underlined on the diagram.
These diagrams look pretty similar, but the intent is different. Instance specifications show instances at one flat level. Composite structure diagrams show internal configurations within a class (or other context, such as a collaboration) and can nest to any level.
回答2:
Role names are found at the opposite end of connectors and denote the name of the instance by which a class references it.
CollaborationRoles are used to represent different implementations (or aspects) of a single use case.
Users (and systems) play roles of Actors.
Instances as described in UML 2.5:
InstanceSpecifications represent instances of Classifiers in a modeled system. They are often used to model example configurations of instances. They may be partial or complete representations of the instances that they correspond to.
来源:https://stackoverflow.com/questions/34119279/difference-between-instances-and-roles-in-uml