Created November 15, 2009
Last updated November 15, 2009
Association
In the relations between the classes, there are the Dependency , Association , Aggregation , Composition , Generalization , Interface-realization and so on
1.
(You may understand that this is a line connected between the classes in the class diagram ).
In this page , I will explain the association that is one of the relations between classes.
I explained that the association is similar to relationship in ER diagram in the page of "
Class diagram , Entity-relationship diagram and Extraction of the class 3. The relation between class diagram and ER diagram".
The exlanation of the page is not a mistake. But ,if only the explanation , I think that you can't program from the class diagram.
Therefore, in this page , I will explain the association so that you may deeply understand.
Especially, I will explain that I think that the beginner is stumble : when there are 2 lines of the associations between the classes and when there is a line of association between itself (reflexive association).
-----
Note.
1:The version of the UML is 2.0.
Actually, it is called Property calling Association End and Attribute generically.
The attribute can be converted into the association and association end completely without changing the meaning.
If you somewhat cut down the meaning , the opposite is also possible 1.
After all, you may think that the association is the same means as the attribute.
Actually, when we program from the class diagram by Java , C/C++ or ExcelVBA , association ends are programed as attributes.
For example, the class diagram in Figure 1 is same means as it in Figure 2.
Figure 1 - the class diagram of telephone book
Figure 2 - the class diagram of telephone book ( converting attributes into association ends in Figure 1.)
The class diagram in Figure 3 is roughly same means as it in Figure 4 (Note: not quite the same).
Figure 3 - Relation between book shelf and book ( using the Biderectionally navigatable association )
Figure 4 - Relation between book shelf and book ( using the Attributes )
-----
Note.
1:"The attribute can be converted into the association and association end completely without changing the meaning." is not a mistake.
But, there is a limitation in opposite conversion.
Because , the expression ability of the association and association end is more than it of the attribute.
For instance , there are the Qualifier , Biderectionally navigatable association 2, Association class and so on.
Those are not able to express by attributs but able to express by associations and association ends.
2:If the Biderectionally navigatable association is converted to the attribute , we can't understand the relation of the objects of the classes.
There are not meny examples that there are two Associations in the books about UML.
But , there are meny examples in the specification of UML 2.0 ( for instance, Figure 7.11 on page 28).
If you can't understand , you may think the Association and Association End to be the Attribute.
The following two class diagrams are the same meanings.
Figure 5 - the class diagram of telephone book
Figure 6 - the class diagram of telephone book ( converting attributes into association ends in Figure 5.)
In the specification of UML 2.0 ,there are everywhere many Reflexive Associations (for instance , Figure 7.3 on page 23 ).
The Reflexive Association is the means that the object of the class has other ( or self ) object of the same class.
If you can't understand , you may think the Association and Association End to be the Attribute.
I will give the example.
Example : Singly Linked List 1
The Singly Linked List is used by realization of the Variable-length array.
If you program by C language , you may use it.
But, because there is the Collection class in ExcelVBA , you don't need to use it.
If you use the Singly Linked List , you can easily add and delete the data. Of course , the data need not be the head or end of the array.
The image of it is the following.
Figure 7 - The image of the Singly Linked List ( This is not a UML diagram )
When data is added on the way, the image of it is the following.
Figure 8 - When data is added on the way ( This is not a UML diagram )
When data is deleted on the way, the image of it is the following.
Figure 9 - When data is deleted on the way ( This is not a UML diagram )
And , the class diagram of it are the followings ( usually right ) .
|
Figure 10 - The class diagram of the Singly Linked List
The multiplicity of the "nextItem" is not "1" but "0..1". This reason is that the last item does't have the next item.
If in C language , it is "NULL". If in ExcelVBA, it is "Nothing". |
-----
Note.
1: The Singly Linked List is the range of the Fundamental Information Technology Engineer Examination (FE) of the
Japan Information-Technology Engineers Examination .
If you think to acquire, study it.
But , when I took the examination , I don't know it. If you don't know it , you can't necessarity pass.
The following table is pages that I refered to create this pate.
I doesn't assume the responsibility of any damage that occurs because of the use of this page.
Microsoft ,Windows ,Visual Basic and Excel are registered trademarks of Microsoft Corporation in the United States and other countries.
Visual Basic® for Applications may represent a VBA.
Mac ,Mac OS ,Mac OS X ,AppleScript are trademarks of Apple Inc., registerd in the U.S. and other countries.
UML ,Unified Modeling Language are trademarks of Object Management Group Inc. in the U.S. and other countries.
Sun, Sun Microsystems, Sun Microsystems Computer Corporation, the Sun logo, the Sun Microsystems Computer Corporation logo, Solaris, Java, JavaSoft, JavaScript, HotJava, JDK, and all Java-based trademarks or logos are trademarks or registered trademarks of Sun Microsystems, Inc.
Other brands and their products are trademarks or registered trademarks of their respective holders and should be noted as such.
The author of this page and these companies do not have any relationship.