It is tempting and in fact common for analysts to use only the class diagram.
After all, the class diagram is the only diagram used to generate code.
The other diagrams are just tools to help understand the classes. Right?
Answer: No, this is not correct.
The problem with this thinking is that the class diagram has a very limited perspective of the problem domain.
The class diagram shows only the static structure of the classes and their relationships to one another. The class diagram does not show how the objects will behave when the system is in use.
The class diagram is like a blueprint for a building. You can see what materials are used, where they are located, and the individual specifications or potential of each component.
For example, you can see the capacity of the power circuits, the size of the water heater, and the heating capacity of the furnace. But you cannot see what happens when a door is left open on a cold day.
You cannot see the change in water temperature after four consecutive showers when everyone gets ready in the morning.
To see the behavior of the resources, you need models that describe how the resources will be used. In these other models, you can see the
interactions between classes, the creation and disposal of resources, and the patterns of collaborations for each behavior.
Class diagrams are the most popular UML diagrams used by the object oriented community.
It describes the objects in a system and their relationships. Class diagram consists of attributes and functions.
A single class diagram describes a specific aspect of the system and the collection of class diagrams represents the whole system. Basically the class diagram represents the static view of a system.
Class diagrams are the only UML diagrams which can be mapped directly with object oriented languages. So it is widely used by the developer community.
Facts are invaluable resources, but to build a software application the modeler has to create a set of
that describe how these facts may be used. The abstraction needs to define what
each resource is, the information it owns, what it can do, and other types of resources with
which it needs to interact to do its job correctly.
Figure 4-1 represents how the UML diagrams uncover facts that support the creation of the
Class diagram. The Class diagram models the facts so that the model represents reality as closely as possible. The Class diagram defines the code that generates the objects. The objects conform to the Class diagram.
Class has Specific Definition
The other UML diagrams model facts as objects and these objects either conform to the rules set
forth in the Class diagram, or they reveal the need for corrections to the rules.
The rules in the Class diagram are used to generate code.
The code generates objects, while the application is running, that behave according to the rules defined by the Class diagram.
Systems may be fairly complex and may require more than one Class diagram. It is
very common to break a subject area down into a set of smaller Class diagrams. Smaller
diagrams are easier to work with and easier to verify, but no matter how many diagrams you
use for the system, each class has only one definition.
Class represents Same Concept
A class represents the same concept no matter where or how often it appears in the diagrams. In a modeling tool, this is accomplished by using a repository. A repository is a shared dictionary, usually built into the modeling tool, of all of the information defined during the modeling process. The first time you add a class to a diagram, a definition is placed into the repository by the tool. Each subsequent time that the class is referenced on a new diagram, the new reference is associated with the existing definition. Consequently, a change made to a class on one diagram is also made to the class definition in the repository, and is reflected in all diagrams that include that class.
Defining all of these rules sounds quite complicated. In truth, the notations of the Class diagram
provide a surprisingly simple yet powerful means to specify everything needed to generate code. With rigor and the proper software support, the Class diagram can even become fully
executable. This means that the model can be tested by executing scenarios and can even
generate the complete application in a variety of implementation environments. But I'm getting
ahead of myself.