UML DESIGN CLASS DIAGRAMS (DCD)
UML class diagrams show the classes of the
system, their inter-relationships, and the operations and attributes of the
classes. Class diagrams are typically used, although not all at once, to:
- Explore domain concepts in the
form of a domain model
- Analyze requirements in the
form of a conceptual/analysis model
- Depict the detailed design of
object-oriented or object-based software
A
class model is comprised of one or more class diagrams and the supporting
specifications that describe model elements including classes, relationships
between classes, and interfaces. There are guidelines for:
Because
class diagrams are used for a variety of purposes - from understanding
requirements to describing your detailed design - you will need to apply a
different style in each circumstance. This section describes style guidelines
pertaining to different types of class diagrams.
- Identify
Responsibilities on Domain Class Diagrams.
- Indicate Visibility Only On
Design Models.
- Indicate Language-Dependent
Visibility With Property Strings.
- Indicate Types Only On Design
Models.
- Indicate
Types On Analysis Models Only When The Type is an Actual Requirement.
- Design Class Diagrams Should
Reflect Language Naming Conventions. In Figure 1 you
see that the design version of the Order class uses names
that conform to common Java
programming conventions such as placementDate and calculateTaxes().
- Model Association Classes On
Analysis Diagrams. Figure 2 shows
that association classes are depicted as class attached via a dashed line
to an association - the association line, the class, and the dashed line
are considered one symbol in the UML.
- Do Not Name Associations That
Have Association Classes.
- Center The Dashed Line of an Association Class.
- Model Relationships
Horizontally
- Collaboration Indicates Need
for a Relationship
- Model a Dependency When The
Relationship is Transitory
- Depict Similar Relationships
Involving A Common Class As A Tree. In Figure 6 you
see that both Delivery and Order have a
dependency on OIDGenerator. Note how the two dependencies are
drawn in combination in "tree configuration", instead of as two
separate lines, to reduce clutter in the diagram.
- Always Indicate the
Multiplicity
- Avoid
a Multiplicity of "*"
- Replace Relationships By
Indicating Attribute Types. In Figure 7 you
see that Customer has a shippingAddress attribute of
type Address - part of the scaffolding code to maintain
the association between customer objects and address objects.
- Do Not Model Implied
Relationships
- Do Not Model Every Single
Dependency
- Center Names on Associations
- Write Concise Association Names
In Active Voice
- Indicate Directionality To
Clarify An Association Name
- Name Unidirectional Associations In The Same Direction
- Word Association Names
Left-To-Right
- Indicate Role Names When
Multiple Associations Between Two Classes Exist
- Indicate Role Names on
Recursive Associations
- Make Associations
Bi-Directional Only When Collaboration Occurs In Both Directions.
The lives at association of Figure 9 is
uni-directional.
- Redraw Inherited Associations Only When Something
Changes
- Question Multiplicities
Involving Minimums And Maximums
7. Aggregation and Composition Guidelines
Sometimes an object is made up of other objects. For example, an airplane is made up of a fuselage, wings, engines, landing gear, flaps, and so on.A delivery shipment contains one or more packages. A team consists of two or more employees. These are all examples of the concept of aggregation, which represents "is part of" relationships.An engine is part of a plane, a package is part of a shipment, and an employee is part of a team.Aggregation is a specialization of association, specifying a whole-part relationship between two objects.Composition is a stronger form of aggregation where the whole and parts have coincident lifetimes, and it is very common for the whole to manage the lifecycle of its parts. From a stylistic point of view, because aggregation and composition are both specializations of association the guidelines for associations apply.
- Apply the Sentence Rule for
Aggregation
- You Should Be Interested In
Both The Whole And The Part
- Depict the Whole to the Left of
the Part
- Apply Composition to Aggregates
of Physical Items
- Apply Composition When the Parts Share The Persistence
Lifecycle With the Whole
- Don't Worry About Getting the
Diamonds Right
- Model Relationships
Horizontally