In this lab, we will discuss UML, the Unified Modeling Language.
Specifically, we will be discussing UML’s Class diagram aspect.
It’s a way of describing class relationships graphically.
These diagrams help us to describe the relationships of classes
in a complex system. They also help us to actually design our classes,
as opposed to “design by coding”.
Understand the Class Diagram
Consider this diagram from
You should understand how the following are indicated (look
here for help):
- class name
- attributes (data members)
- actions (methods)
- an abstract class
- aggregation (has-a)
- generalization (inheritance, is-a)
- multiplicity of association
- navigability of association
Creating a Class Diagram
Now, consider the following classes:
- can be either a GM, a Ford, or a Chrysler
- has exactly four Tires
- can be started or stopped
- can hold up to four Passengers
- Draw a class diagram for these objects.
- Indicate any abstract classes.
- Give each class attributes and operations, as needed.
- Draw association lines between classes.
- Add multiplicities.
- Add generalization triangles.
- Add association navigability arrows.
For the tasks in that list, there are no hard right or wrong answers.
Should a Tire have a pointer to its associated Car?
Where do I use aggregation, as opposed to association?
These are design questions.