Class Diagram
Class Diagram
creating objects. Objects are instances of classes, and each class defines a set of
attributes (data members) and methods (functions or procedures) that the objects
created from that class will possess. The attributes represent the characteristics
or properties of the object, while the methods define the behaviors or actions
1. Class Name:
The name of the class is typically written in the top compartment of the
of the class. They are listed in the second compartment of the class box
and often include the visibility (e.g., public, private) and the data type of
each attribute.
3. Methods:
the class box and include the visibility (e.g., public, private), return type,
4. Visibility Notation:
package)
UML is not just about pretty pictures. If used correctly, UML precisely conveys
implemented code will correctly reflect the intent of the designer. Can you
describe what each of the relationships mean relative to your target
If you can't yet recognize them, no problem this section is meant to help you to
types:
and a more specific classifier. Each instance of the specific classifier is also an
indirect instance of the general classifier. Thus, the specific classifier inherits
line with a hollow arrowhead that points from the child element to the parent
element.
The figure below shows an inheritance example with two styles. Although the
Association
Associations are relationships between classes in a UML Class Diagram. They
are represented by a solid line between classes. Associations are typically named
using a verb or verb phrase which reflects the real world problem domain.
Simple Association
association that connects the <<control>> class Class1 and <<boundary>> class
Class2. The relationship is displayed as a solid line connecting the two classes.
Cardinality
one to one
one to many
many to many
Aggregation
displayed as a solid line with a unfilled diamond at the association end, which
Composition
A special type of aggregation where parts are destroyed when the whole is
destroyed.
Objects of Class2 live and die with Class1.
displayed as a solid line with a filled diamond at the association end, which is
Dependency
An object of one class might use an object of another class in the code of a
method. If the object is not stored in any field, then this is modeled as a
dependency relationship.
Exists between two classes if changes to the definition of one may cause changes
might have a hasRead method with a Book parameter that returns true if the
Realization
realize the blueprint class. In other words, you can understand this as the
For example, the Owner interface might specify methods for acquiring property