Monday, July 23, 2007

Modeling an Association

A software application requires a set of resources. To use them you need to describe each resource using a class definition. Classes describes the type of resources, their purpose, and the features that they provide, including attributes and operations.

Relationship explain how they can communicate. UML relationships come in three different types
association
generalization
dependency
Association is a semantic relationship between two model elements. i.e defines the rules that apply to relationships between the objects defined by participating classes.

Generalization is used in the context of inheritance. Defines the organization of information about objects that share the same semantic meaning but which vary in their individual features.

Dependency relationship does not require direct communication. An object relies on fact that another object exists and doing or has done, its job.

The purpose of an association is to establish the reason why two classes of objects need to know about one another, and rules that govern the relationship.
Modeling an association begins by identifying the participating classes.

1. Binary association notation
Associations that use two particiapting classes is called binary association.
Association is a rule that explaints what is allowed.
It documents the rules that govern one relationship between two classes of objects.



Figure 6-1: Association is a type of relationship. A link is an instance, or implementation, of an association.

Association name is in the middle of the line between two classes

an Event is hosted by Venue



Figure 6-3: An association's name uses a verb or verb phrase.



Figure 6-4: Each association represents a separate set of rules.


Association end

To define those roles, UML treats each association end as a separate and distinct entity with its own rules.


Figure 6-5: Association ends define the participation of each type of object.

Each end of the association includes some or all of these defining features;
-Roles
-Interface specifier
-visibility
-multiplicity
-ordering
-constraints
-qualifier
-navigability
-changeability
Roles
How an object participates in the relationship.

UML defines three extension mechanisms:
tagged values
stereotypes
constraints
Constraints are really just strings, you can add as many constraints as you need between the pairs of braces{}. It define which objects are allowed to participate in an association. It placed in an unambiguous place at the end of the association and near the class it applies to.


Figure 6-12: Using constraints to restrict object participation.


Qualifier
It works very much like a key on an indexed file. Provides a means to go directly to the object you want. The qualifier defines an attribute of the referenced objects and uses it as a key to get direct access to a specific object. To model a qualifier you must identify the type of object that wants to use the access, and the type of object that provides the access. The qualifier is placed next to the type of object that want to use it.


Figure 6-13: Using a qualifier to get direct access to an object.
The rectangle containing the qualifier is inserted between the class and the end of the association so that all the other association end notation remains intact.

Navigability
Describes the need for an object to access another object. It modeled with an arrow on the end of the association. Most associations are bi-directional. so, does not show any arrows.



Figure 6-14: Specify navigation by placing an arrow at the end of the association


Changeability
Enables you to specify the operations that are allowed on the links defined by an association. The default changeability is to allow any type of edit-add, change, delete, and move. The predefined options include {frozen}, which means that once the link has been esatablished, it cannot be changed or mved.


Figure 6-15: Modeling the non-default changeability property {frozen}.



Constraints between associations


Handle a situation where two associations are mutually exclusively. ie a venue manager may oversee an event or audit an event, but not both. Draw a dashed line between the two associations. Place the {xor} near the dashed line. It states that only one of the two associations may be instantiated between the pair of objects.


Figure 6-16: Exclusive or constraint on two associations {xor}.


Reflexive association
Most associations are between objects of two different classes. When the participating objects are in two different classes, the association line comes out of one class and into another class.


Derived associations
It using, because when a model becomes large or complex, it can become difficult to navigate to the information you needed.

No comments: