Problem Analysis  «Prev 

Many to Many - Modeling Advanced Associations


A specification describes the behavior or structure of something without determining how the behavior will be implemented. An implementation provides the details about how to implement behavior in an effectively computable way. The relationship between an element that specifies behavior and one that provides an implementation is called realization. In general, there are many ways to realize a specification. Similarly, an element can realize more than one specification. Realization[1] is therefore a many-to-many relationship among elements.of structure or implementation.

The meaning of realization is that the client element must support all the behavior of the supplier element but need not match its structure or implementation. A client classifier, for example, must support the operations of the supplier classifier, and it must support all state machines that specify external behavior of the supplier. But any attributes, associations, methods, or state machines of the supplier that specify implementation are irrelevant to the client. Note that the client does not actually inherit the operations from the supplier. It must declare them itself or inherit them from an ancestor so that all the operations of the supplier are covered. In other words, the supplier in a realization indicates which operations must be present in the client, but the client is responsible for providing them. In the most general sense of realization, the names of the operations need not match, only their total behavior.
Certain kinds of elements, such as interfaces and use cases, are intended for specifying behavior, and they contain no implementation information. Other kinds of elements, such as classes, are intended for implementing behavior. They contain implementation information, but they can also be used in a more abstract way as specifiers. Usually, realization relates a specification element, such as a use case or an interface, to an implementation element, such as a collaboration or a class. It is possible to use an implementation element, such as a class, for specification. It can be placed on the specification side of a realization relationship. In this case, only the specification parts of the supplier class affect the client. The implementation parts are irrelevant for the realization relationship. More precisely, then, realization is a relationship between two elements in which the external behavior specification parts of one constrain the implementation of the other. It might be thought of as inheritance of behavior specification without inheritance.

UML Distilled

Modeling advanced associations

1) Examine many to many associations. Ask 'Is there information that we need about the links in this association?'

2) Identify the information that you need to track. Sometimes it will be a single attribute.
Sometimes it could be attributes and operations.

3) Place the information in a class definition

4) Attach the new class to the association using a dashed line. This method shows how you arrived at the need for a new class. It encapsulates everything you need to know about the relationship between objects in the association.

5) To implement the class you might later need to promote it to the status of a regular class. To do so, replace the original association and dashed lines with two new associations. Draw one association from the association class to one of the original class.

6) Name and redefine the multiplicity of the new association.

7) Repeat the process for the association between the association class and the other original class.

8) Delete the original association that has now been completely replaced.

[1] Realization: When a class implements an interface specified by another class (or interface, as in Java).