1 / 10 Unified Modeling Language (UML) Class Diagram Miaoqing Huang University of Arkansas Spring 2010
2 / 10 Outline 1 2
3 / 10 Class Diagram Class diagrams show the static structure of the classes that make up a system or subsystem Use case diagrams show the functional requirements of a system (or subsystem) from the perspective of the end-user of a system
4 / 10 Classes Classes are shown as rectangles Class name Other compartments Attributes Operations Other predefined compartments Name convention Class name Have no space between multiple words Capitalize the first letter in each subsequent world Name of features in compartments Have no space between multiple words Capitalize the first letter in each subsequent world except the first world
Associations among classes Associations represent relationships between (instances of) classes Classes collaborate with each other by passing messages and receiving responses Association name Indicates the nature of the association Associate name should begin with a capital letter Navigability: use arrow to indicate how to interpret the association Unidirectional association Bidirectional association: without arrow Role name Indicate the role played by a class in an association Attached to the corresponding association end Can use the same rule of naming features to name the role, i.e., low case the very first letter and capitalize the first letter of subsequent word 5 / 10
6 / 10 Multiplicity Multiplicity indicates how many objects may participate in the given relationship (during the run-time of your software system) *: 0..infinity 1: 1..1 n..m: low_bound..up_bound Multiplicity of an association end is not shown The multiplicity is not known The multiplicity is not specified
7 / 10 Aggregation Aggregation symbol. Assembly consists of components. Component is part of an assembly Aggregation association An instance of one class may consist of instances of another class whole-part association whole is made up of parts Use a solid line with a unfilled diamond shape at the end Diamond is connected to the class that is the aggregate A part is capable existence outside of whole-part association
8 / 10 Composition Document Document FrontMatter 1 1..* 0..1 Section 1..* 0..1 Index FrontMatter [1] Section [1..*] Index [0..1] Composition association whole-part association The life-cycle of the part cannot extend beyond the life-cycle of the whole Two different notations Filled diamond notation Graphical containment 1..* 0..1
9 / 10 Generalization Generalization relationship is (sometimes) described as being a kind of relationship Generalized class: superclass (supertype) Specialization: subclass (subtype) Generalization allows the inheritance of the attributes and operations of a superclass by its subclasses Subclass can override the operations in the superclass
More on attribute and operation Attribute and Operation Types feature-name : type Attribute and Operation Visibility private (-) The feature is available only within the class that owns the feature public (+) The feature is available to any class associated with the class that owns the feature protected (#) The feature is available within the class that owns that feature and any subtype of that class package ( ) The feature is available only to other classes in the same package 10 / 10