A recursive association connects a single class type (serving in one role) to itself (serving in another role).
Example:
Admin staffs are in-charge admitting inpatient to the hospital.
Several nurses work in each ward and one of them is in charge of the ward.
Worker works for Manager
and Worker and Manager
both are 2 roles of Employee
One team is assigned the task of supervising the other teams.
This supervisor team makes sure that each team records its portion of the data.
The supervision relationship is a recursive relationship because the same entity, a particular team, participates more than once in the relationship, as a supervisor and as a supervisee.
Multiplicity defines how many objects participate in a relationship and it is the number of instances of one class related to one instance of the other class.
Place multiplicity notations near the ends of an association.
These symbols indicate the number of instances of one class linked to one instance of the other class.
one company will have one or more employees, but each employee works for one company only.
Make Class Diagram:
• An airport is a start (location) for one or more flight numbers.
• A flight number has as destination exactly one airport.
An association is assumed to be bidirectional,
which means that you can navigate from either class to the other one.
However, you can specify that navigation can only occur from one class to another by using a feathered arrow,
as shown in Figure:
Navigability arrows in the class indicate in which direction an association can be traversed and are based on the collaboration modeled in communication and sequence diagrams.
Establishing the navigation arrow on this association means that a Customer has access to his or her Password, but no one can in turn use a Password to identify a Customer.
Navigation is optional and indicates whether a class may be referenced from the other classes in an association.
If no arrows are present, associations are assumed to be navigable in all directions, and all classes involved in the association may reference one another.
Figure shows navigation arrows applied to an n-ary association. Given a worker, you can reference his work products and units of work to determine his utilization, but given a work product or unit of work, you are unable to determine its utilization by a worker.
- Named associations can be given in any order, but if both positional and named associations are used in the same call, positional associations must occur first, at their normal position. Hence once a named association is used, the rest of the call must use only named associations.
- Use named parameter association in calls of infrequently used subprograms or entries with many formal parameters.
- Use named association when instantiating generics.
- Use named association for clarification when the actual parameter is any literal or expression.
- Use named association when supplying a non default value to an optional parameter.
- An association can have a name that indicates the nature of the relationship. If a name is present, there can also be a triangle that points in the direction in which you should read the name.
- Aggregation is a way of composing different abstractions together in defining a class.
- Ex. A car class can be defined to contain other classes such as engine class, seat class, wheels class etc. The car class can define an engine class as one of its attributes.
- Objects could share other objects. When ford and fiat are using the same engine design, it is possible for them to share one engine design object. In such a case, engine design object is said to be nominally part of car design object.
- It is a specialized form of Association where all object have their own lifecycle but there is ownership. This represents “whole-part or a-part-of” relationship. This is represented by a hollow diamond followed by a line.
Association is relation between two separate classes which establishes through their Objects. Association can be one-to-one, one-to-many, many-to-one, many-to-many.
Aggregation It is a special form of Association where:
- It represents Has-A relationship.
- It is a unidirectional association i.e. a one way relationship.
Composition is a restricted form of Aggregation in which two entities are highly dependent on each other.
- It represents part-of relationship.
- In composition, both the entities are dependent on each other.
- When there is a composition between two entities, the composed object cannot exist without the other entity.
- Dependency: Aggregation implies a relationship where the child can exist independently of the parent. For example, Bank and Employee, delete the Bank and the Employee still exist. whereas Composition implies a relationship where the child cannot exist independent of the parent. Example: Human and heart, heart don’t exist separate to a Human.
- Type of Relationship: Aggregation relation is “has-a” and composition is “part-of” relation.
- Type of association: Composition is a strong Association whereas Aggregation is a weak Association.
- Delegation allows the behavior of an object to be defined in terms of the behavior of another object.
- The term 'delegation' refers to the delegation of responsibility.
- The primary emphasis of delegation is on message passing where an object could delegate responsibility of a message it couldn't handle to objects that potentially could (its delegates).
- Delegation can be explicit or implicit. With explicit delegation an object can explicitly delegate a message to any other object it has knowledge of. With implicit delegation an object can explicitly designate another object as its "parent". Messages that are not understood by the receiving object are automatically (implicitly) delegated to this parent.
- Delegation is alternative to class inheritance. Delegation is a way of making object composition as powerful as inheritance.
- In delegation, two objects are involved in handling a request: receiving object delegates operations to its delegate. This is analogous to the child classes sending requests to the parent classes.