You are on page 1of 6

Association

• Special Constraints
• UML Defines five constraints that may be applied to
association
• Implicit – specifies that relationship is conceptual
• Ordered – specifies that the sets of objects at one end of an
association are in an explicit order
• Changeable – links between objects may be added,
removed and changed feely
• Addonly – New links may be added from an object on the
opposite end of the association
• Frozen – a link, once added from an object on the opposite
end of the association, may not be modified or deleted
Association contd…
• Frozen – a link, once added from an object on the opposite
end of the association, may not be modified or deleted

3..*
Polygon Points
{Ordered}
Generalization
• A descendant class cannot omit or supress an ancestor attribute. It
inherits all attributes and all operation. A Subclass may
reimplement an operation for reasons of efficiency but cannot
change the external Protocol or signature.
• A subclass can be an extension or a restriction. Extension adds
new feature to subclass. A restriction restricts values that instances
can assume.

Ellipse

Employee Major axis


Minor axis

Inherited feature can be renamed in a restriction Circle


Hourly Salaried Exempt
Diameter
Generalization contd…

• Overriding method substantially differs from overridden method


• Overriding is done for following reasons
• Overriding for extension – The new operation is same as inherited,
except it adds some behavior for the extended attribute
• Overriding for restriction – The new operation restricts the protocol.
Scale operation for ellipse shows growth in both x and y. In case of
circle scaling will only change the diameter thus scaled object will also
be a circle
• Overriding for optimization – An implementation can take advantage
of the constraints imposed by a restriction to improve code for an
operation, area calculation is easy for a rectangle
• Overriding for convenience – A common practice in developing new
classes is to look for a class similar to what is desired and override the
methods that are inconvenient. This is semantically wrong
Semantic rules for inheritance
• All query operations are inherited by all subclasses
• All update operations are inherited across all extensions
• Update operations that change constrained attributes or
association are blocked across a restriction
• Operations may not be overridden to behave differently from
inherited operations. All methods that implement an operation
have the same protocol
• Inherited operations can be refined by adding additional
behavior
• UML specifies one stereotype and four special constraints that
can be applied to generalization relationship
• Implementation – this stereotype specifies that the child inherits
the implementation of the parent but does not support interfaces
thereby violating substitutability. Maps to private inheritance as
found in C++
• A stack is implemented using an array but does not exhibit its
behavior, or can be substituted for an array
There are four constraints

• Complete – all children in the generalization have been


specified and no additional children are permitted

• Incomplete – Not all children in the generalization have been


specified and that additional children are permitted

• Disjoint – An object instance will belong to only one subclass

• Overlapping – An object instance may belong to more than


once subclass