B. Class Diagram.
I learn the class diagram from IBM (2004) web site.
B1. Scope of class diagram
Class diagram provides an initial set of notation elements that all other structure diagrams use.
B2. The elements of class diagram
- Class - UML uses a special name for these types: "classifiers." Generally, you can think of a classifier as a class, but technically a classifier is a more general term that refers to the other three types above as well. The UML representation of a class is a rectangle containing three compartments stacked vertically, as shown in the figure 1. The top compartment shows the class's name. The middle compartment lists the class's attributes. The bottom compartment lists the class's operations. When drawing a class element on a class diagram, you must use the top compartment, and the bottom two compartments are optional. (The bottom two would be unnecessary on a diagram depicting a higher level of detail in which the purpose is to show only the relationship between the classifiers.

- Inheritance - It refers to the ability of one class (child class) to inherit the identical functionality of another class (super class), and then add new functionality of its own. To model inheritance on a class diagram, a solid line is drawn from the child class (the class inheriting the behavior) with a closed, unfilled arrowhead (or triangle) pointing to the super class. (See figure 2)
Figure 2. Inheritance layout of class diagram.
- Bi-directional (standard) association -An association is a linkage between two classes. Associations are always assumed to be bi-directional; this means that both classes are aware of each other and their relationship, unless you qualify the association as some other type. Going back to our Flight example, the below figure shows a standard kind of association between the Flight class and the Plane class (See figure 3).

Figure 3. Association layout of class diagram
- Packages - Packages enable modelers to organize the model's classifiers into namespaces, which is sort of like folders in a filing system. Dividing a system into multiple packages makes the system easier to understand, especially if each package represents a specific part of the system.(See figure 4)

Figure 4. Packages layout of class diagram.
- Interfaces - It is considered to be a specialization of a class modeling element, please see the below figure that is an example package element that shows its members inside the package's rectangle boundaries. (See figure 5)
- Aggregation - It is a special type of association used to model a "whole to its parts" relationship. In basic aggregation relationships, the lifecycle of a part class is independent from the whole class's lifecycle. There are 2 types of aggregation, the first one is basic aggregation that is an association with an aggregation relationship indicates that one class is a part of another class. In this kind of aggregation relationship, the child class instance can outlive its parent class (See figure 6). The second one is Composition aggregation that is the composition aggregation relationship that is just another form of the aggregation relationship, but the child class's instance lifecycle is dependent on the parent class's instance lifecycle.(See figure 7).
Figure 5. Interfaces layout of class diagram.

Figure 6. The basic aggregation of class diagram

Referances:
IBM (2004). "UML basics: The class diagram". Received 5th May, 2009 from URL - http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/
沒有留言:
發佈留言