Classifiers and Instances
Some types of element (such as Classes) model classifications, which provide a specification of an abstract concept. For example, the concept of a Building can be represented by a set of Classes that define types of building such as Bungalow, Miner's Cottage, Office Block, Shop and so on. Other types of element (such as Objects) model instances of such classifications, such as 23 High Street Shop or 45 Village Green Cottage. The instance elements represent actual objects in a run-time scenario, based on the specification of the classifier element. For example:
- An Object element represents a man called Joe Smith, as a specific instance of the concept of 'a person' defined by the Class element Person; the object is rendered as a rectangle showing the name of the classifier - if you name the object it becomes <ObjectName>:<ClassifierName> or, in this example, Joe Smith:Person
If you develop a Person Class with attributes such as Age, Name, Address and Sex, and functions such as GetAge and GetName, then when you derive an object from that Class the object takes on all the Person Class behavior and state (as well as inherited state and behavior from Person's parent elements, if any).
Associating an instance with a classifier greatly increases the descriptive power of the model in capturing the functionality and responsibility of objects and their associated state at run-time. This is a powerful means of moving your model from the analysis phase into detailed design.
- An object is an instance of a classifier at runtime, so the object's features are actually those of the classifier; in the context menu for a classified object, if you select the 'Attributes' or 'Operations' menu options, the 'Features' dialog displays for the classifier, not the object
- Similarly, if you have set the classifier for an object in a Sequence diagram, when you add a message and display its 'Message Properties' dialog, the 'Message' drop-down list is drawn from the operations of the target object's classifier, not from the object itself
In this way you can associate Sequence diagram objects with Classes and use the defined behavior of the Class to model actual behavior at run time; the same concept applies to Messages for a State Flow connector
- In the 'Message' dialog, you can also select to include messages defined in the inheritance hierarchy of the classifier for the target object