Unified Modeling Language/Class diagram

From Citizendium
< Unified Modeling Language
Revision as of 11:28, 17 November 2008 by imported>Eric Evers
Jump to navigation Jump to search

A class diagram is one of the most popular types of UML diagrams.

Class Diagrams use implements, composition and aggregation relationships.

----------------------------------------------------
Implementation example:  A fedora is a (type of) hat. 
Arrowhead type:          Unfilled closed triangle.
Arrow direction:         From example to category.
+--------+
| hat    |
+--------+
    ∆
    |
    |
+--------+
| fedora |
+--------+
 
------------------------------------------------------------------
Composition example:  A heart is a non-removable part of a person. 
Arrowhead type:       Solid diamond.
Arrow direction:      From part to whole.
+--------+
| person |
+--------+
    ♦
    |
    |
+--------+
| heart  |
+--------+
----------------------------------------------------------
Aggregation example:  A hat is a removable part of a person. 
Arrowhead type:       Unfilled-diamond(lozenge).
Arrow direction:      From part to whole.
+--------+
| person |
+--------+
    ◊
    |
    |
+--------+
|  hat   |
+--------+
----------------------------------------------------------
Inner Class example:  Tree_search is an inner class of tree.  
Arrowhead type:       Oplus(plus in a circle).
Arrow direction:      From part to whole.
Purpose:              Tree_search is a Search, but Tree_Search 
                      is an inner class of tree.
                      Only trees need a tree_search class 
                      so it is hidden. Some languages do not
                      support inner classes. Java does.
+--------+   +---------+
| tree   |   | search  |
+--------+   +---------+
    ⊕        / \
    |         |
    |         |
+-------------+
| tree_search |
+-------------+