Def.- A property is a special structural feature that if it belongs to a class, is an attribute.
(However, it can also belong to an association. But more about this later).
Notation & Semantics
An attribute is a (data) element that is equally contained in every object of a class and that is represented by an individual value in each object.
Attributes have no identity outside the object to which they belong.
Attributes are fully under the control of the objects of which they are part.
Proposal:
(both diagrams mean the same thing -- we should only have one way of specifying this; it is only the rendering that is different)
Example Attributes
# Syntax: [visibility][/] name [:type][multiplicity][=initial value][{property string}]
# Visibility:
# - + public: it can be seen and used by all.
# - -private: only the class itself can get hold of private attributes.
# - #protected: both the class itself and its subclasses have access.
# - ~ package: only classes from the same package can access these attributes.
# - / symbolizes a derived attribute.
# - Multiplicity is in square brackets (e.g. [1..*]).
# - Default value specifies the initial value of the attribute.
# Property string indicates a modifier that applies to the attribute:
# - {readonly}: the property can be read but not changed.
# - {union}: the property is a union of subsets.
# - {subsets <property>}: the property is a subset of <property>.
# - {redefines <property>}: the property is a new definition of <property> (overwritten by inheritance).
# Multiplicity collection classes
# ordered set {ordered}
# set {set}
# ordered list {sequence}
# {bag}
class Customer {
-bookings: Bookings[0..*]
}
Attribute full syntax
[visibility][/] name [:type][multiplicity][=initial value][{property string}]
Where:
Visibility:
+public: it can be seen and used by all.
-private: only the class itself can get hold of private attributes.
protected: both the class itself and its subclasses have access.
~package: only classes from the same package can access these attributes.
/ symbolizes a derived attribute.
Multiplicity is in square brackets (e.g. [1..*]).
Default value specifies the initial value of the attribute.
Property string indicates a modifier that applies to the attribute:
{readonly}: the property can be read but not changed.
{union}: the property is a union of subsets.
{subsets }: the property is a subset of .
{redefines }: the property is a new definition of (overwritten by inheritance).
Property string indicates a modifier that applies to the attribute:
{ordered}, {unordered}: an ordered or unordered set.
{unique}, {nonunique} or {bag}: a set may or may not contain several identical elements.
{sequence}: an ordered list (array; identical elements permitted).
{composite}: the property is an existence-dependent part and others.
If the multiplicity is greater than 1, then the attribute represents a set.
Additional information can be specified for the order (isOrdered) and uniqueness (isUnique). (see Multiplicity metamodel).
Depending on the combination of these two pieces of information, we obtain different collection classes (see next table).
IsUnique
isOrdered
Collection Class
Yes
Yes
Ordered set {ordered}
Yes
No
Set (default)
No
Yes
Ordered list {sequence}
No
No
{bag}
class Customer {
-booker: Booking[1]
}
class Booking {
-bookings: Customer[0..*]
}
Properties
Notation & Semantics
Proposal: (both diagrams mean the same thing -- we should only have one way of specifying this; it is only the rendering that is different)
Attribute full syntax
[visibility][/] name [:type][multiplicity][=initial value][{property string}]
Where:
Visibility:
protected: both the class itself and its subclasses have access.
/
symbolizes a derived attribute.Multiplicity is in square brackets (e.g. [1..*]).
Default value specifies the initial value of the attribute.
Property string indicates a modifier that applies to the attribute:
Property string indicates a modifier that applies to the attribute:
If the multiplicity is greater than 1, then the attribute represents a set.
Additional information can be specified for the order (isOrdered) and uniqueness (isUnique). (see Multiplicity metamodel).
Depending on the combination of these two pieces of information, we obtain different collection classes (see next table).
Examples of multiplicity collection classes
name:String = ‘unknown’
birthDate:Date
radius: Integer = 25 {readonly}
/age:Integer {age=today-birthDate}
-versionNo:Integer
time:DateTime::Time
dynamArray[*] {ordered}
name:String[1]
firstName:String[0..1]
firstNames:String[1..5]