UML Property

A property is a structural feature which could represent

As a structural feature, property represents some named part of the structure of a classifier. For example, Patient class could have id, name, gender, date of birth, etc. as its properties.

Attributes of Patient class are id, name, gender, birth date, home address, visits.

Attributes (properties) of Patient class are
id, name, gender, birth date, home address, visits.

When instance of a classifier is created, each non static property becomes a part of the state of that instance, and is implemented by some mapping of the name of the property to a specific value or values that the state of the instance is composed of. Values of each property have specific type and are allocated in the slots of the instance or associated with that instance.

Slots are shown with the feature name followed by an equal sign and a value.

Instance newPatient of the Patient class
has slots with values specified.

The general syntax for properties is shown below:

property ::= [ visibility ]  ['/']   property-name   [ ':' property-type ]   [ '[' multiplicity ']' ]   [ '=' default-value ]   [ property-modifiers ]
visibility ::=   '+'   |   '~' |   '#'   |   '-'  
property-modifiers ::= '{' property-modifier   [   ','   property-modifier ] *   '}'
property-modifier ::=   'id'  |  'readOnly'  |  'ordered'  |  (  'seq'  |  'sequence'  )  |  'unique'  |  'nonunique'   |   'union'  | 
                'redefines'   property-name  |  'subsets'   property-name  |  property-constraint  

Optional visibility is the visibility of the property. Note, that there is no default visibility. Also, visibility may be suppressed from being displayed on a diagram, even if it has some value in the model (e.g. stored by UML tool). So, if visibility is not shown on a diagram, it was either not specified or suppressed.

Forward slash '/' means that the property is derived.

The property-type is the type of the property represented by the name of classifier.

Property could have multiplicity. The multiplicity bounds constrain the size of the collection of property values. By default the maximum bound is 1.

The default-value option is an expression for the default value or values of the property.

Property may have optional modifiers:

ModifierDescription
id Property is part of the identifier for the class which owns the property.
readOnly Property is read only (isReadOnly = true).
ordered Property is ordered (isOrdered = true).
unique Multi-valued property has no duplicate values (isUnique = true).
nonunique Multi-valued property may have duplicate values (isUnique = false).
sequence (or seq) Property is an ordered bag (isUnique = false and isOrdered = true).
union Property is a derived union of its subsets.
redefines property-name Property redefines an inherited property named property-name.
subsets property-name Property is a subset of the property named property-name.
property-constraint A constraint that applies to the property

Attribute

Older UML 1.x specifications, e.g. UML 1.4.2 Specification, defined attribute as a named slot within a classifier that describes a range of values that instances of the classifier may hold."

In UML 2.x a property owned by a classifier represents an attribute of the classifier. Context of the attribute is the owning classifier.

For example, Patient class may have id, name, gender, date of birth, etc. as its attributes.

Attributes of Patient class are id, name, gender, birth date, home address, visits.

Attributes of Patient class are
id, name, gender, birth date, home address, visits.

UML specification very vaguely describes ownership of (non static) attribute as some relationship when the value or values related to the instance of the classifier are being held in the slots of the instance.

Slot is UML element which specifies that an instance has a value or values for a specific structural feature. UML specification also says that a slot gives the value or values of a structural feature of the instance. An instance can have one slot per structural feature of its classifiers, including inherited features.

In programming we would call this kind of mapping as memory slots or storage. In plain English, attributes of classifier are stored in slots of the classifier.

When instance of a classifier is created, each non static property becomes a part of the state of that instance, and is implemented by some mapping of the name of the property to a specific value or values that the state of the instance is composed of. Values of each property have specific type and are allocated in the slots of the instance or associated with that instance.

Slots are shown with the feature name followed by an equal sign and a value.

Instance newPatient of the Patient class
has slots with values specified.

Attribute Vs. Member End of Composition or Association

Specifications and User Guides of the older UML 1.x versions considered attribute as a shortcut or semantic equivalent of the composition. For example, UML 1.4.2 Specification explained:

Note that an attribute is semantically equivalent to a composition association; however, the intent and usage is normally different.

(It would be really helpful to see some explanation of what exactly that snobbish "normally different intent and usage" might mean, so the next citation provides some clue.)

The class symbol may be thought of as an example of the composition nesting notation (with some special layout properties). However, attribute notation subordinates the attributes strongly within the class; therefore, it should be used when the structure and identity of the attribute objects themselves is unimportant outside the class.

In UML 1.x they also called it "different ways to show composition", so that the example of the Patient class with attributes shown above could be also rendered using composition instead of some attributes.

Address and visits attributes of the Patient class shown as composition, as allowed by UML 1.x.

Address and visits attributes of the Patient class
shown here as two compositions, as allowed by UML 1.x.

UML 2.x specifications allow to show an attribute using notation for association, so that that previous example of the Patient class could be rendered in UML 2.5 as shown below.

Address and visits attributes of the Patient class may be shown using association notation in UML 2.x.

Address and visits attributes of the Patient class
may be shown using association notation in UML 2.x.

Note, that the ownership of association ends by the associated Patient class is indicated graphically by a small filled circles (aka dots, see explanations following). Also note, that there are no adornments (decorations) at the association ends connected to the class.

Association Member End

When a property is an association end, the value or values of the property are related to the instance or instances at the other end(s) of the association.

A property owned by an association represents an attribute of the association and is named member end. In the case of an association end context is the set of types at the other end or ends of the association.

Association end could be owned either by

Association ends of associations with more than two ends must be owned by the association.

UML standard does not mandate the use of explicit end-ownership notation, but defines a default. When dot notation is not used in binary association, association ends are assumed to be owned by association.

Member End of Association Vs. Attribute

Classifier attribute may represent an association end when this association end is owned by the classifier.

Ownership of association ends by an associated classifier may be indicated graphically by a small filled circle (aka dot). The dot is drawn at the point where line meets the classifier. It could be interpreted as showing that the model includes a property of the type represented by the classifier touched by the dot. This property is owned by the classifier at the other end.

Ownership of association ends by association and classifier

Association end query is owned by classifier QueryBuilder
and association end qbuilder is owned by association Builds itself

Qualifier

A property may have other properties (attributes) that serve as qualifiers. A qualifier is a property which defines a partition of the set of associated instances with respect to an instance at the qualified end. (And probably more appropriate name for qualifier would be selector or key.)

Qualifiers are used to model hash maps in Java, dictionaries in C#, index tables, etc. where fast access to linked object(s) is provided using qualifier as a hash key, search argument or index.

A qualifier is shown as a small rectangle attached to the qualified classifier also called the source. This qualifier rectangle is part of the association, not part of the classifier. UML does not allow qualifier to be suppressed.

One or several attributes of the qualifier are drawn within the qualifier box, one to a line. Qualifier attributes have the same notation as classifier attributes, except that initial values are not used in this case.

UML allows having a qualifier on each end of a single association.

Multiplicity of Target

Given a qualified object and a qualifier instance, the number of objects at the target end of the association is constrained by the declared multiplicity of the target.

Target multiplicity should allow 0 ("no results") if the domain of the qualifier is large or infinite, e.g. number, long string, date. It can be exactly 1 for qualifiers of enumerated or restricted domain.

In the case in which the target multiplicity is 0..1, the qualifier value is unique with respect to the qualified object, and links to at most one associated object.

Association qualifier allows search of employee by SSN.

Given a company and a social security number (SSN)
at most one employee could be found

In the case of target multiplicity 0..*, the set of associated instances is partitioned into possibly empty subsets, each selected by a given qualifier instance.

Association qualifier allows book search by author.

Given a library and author name none to many books could be found

Target multiplicity should allow 0 if the domain of the qualifier is large or infinite, e.g. number, long string, date.

Multiplicity of Qualifier

UML 2.4 specification is mumbo jumbo gibberish explaining multiplicity of qualifier:

The multiplicity of a qualifier is given assuming that the qualifier value is supplied. The “raw” multiplicity without the qualifier is assumed to be 0..*. This is not fully general but it is almost always adequate, as a situation in which the raw multiplicity is 1 would best be modeled without a qualifier.

Association qualifier could have multiplicities at both ends.

Given chessboard and specific rank and file we'll locate exactly 1 square.
UML specification provides no lucid explanation of what multiplicity 1 means for qualifier.

Next  Operation