Course 05
Course 05
Software Engineering
Class
Dr. S. A. Medjahed 1
Introduction
•As we mentioned in the previous chapter, the use case diagram shows the
major functionalities of the system and the actors triggering them. The class
diagram shows us the internal structure of the system. It provides an
abstract representation of the system objects that will interact to realize the
use cases.
•This is a static view, because the temporal factor in the behavior of the
system is not taken into account. The class diagram models the concepts of
the application domain by presenting the classes of the system and their
relationships.
•The main elements of this static view are classes and their relationships:
association, generalization, and several types of dependencies.
Dr. S. A. Medjahed 2
Class
•A class is the abstract description of a set of objects that are part of the
same domain (possessing the same characteristics).
•A class is represented by a workbook divided into three parts:
The name of the class that begins
always with a capital letter.
The attributes that represent the data Class Name
of the object. Attributes
behavior of an object
Dr. S. A. Medjahed 3
Encapsulation
• The user can use a class (create/manipulate objects) without knowing the body of the class. If the class is properly defined,
the user cannot violate the integrity of the object [e.g., transform an ordered list into an unordered list].
Dr. S. A. Medjahed 4
The Legacy
• An object of the class "Motor Vehicle" inherits the properties of the class "Vehicle". So, such an object has a weight, a size and
a price. In addition, it can stop and start. In addition, it has a power and a top speed (properties that vehicles without an
engine do not have).
• VehicleMotor " is said to be derived (or inherited) from the class "Vehicle".
Dr. S. A. Medjahed 5
Polymorphism
• These are multiple forms for the same operation.
• Example: It is impossible to calculate the surface area of a graphic shape if we have no information
about this shape [the graphic shape class is therefore an abstract class].
Dr. S. A. Medjahed 6
Class Diagram
A class diagram shows the static structure of a system. It allows the visualization of classes and the relationships between them
. Its purpose is to explain what to achieve rather than to explain how to achieve it.
Dr. S. A. Medjahed 7
Example of a class
Student
Dr. S. A. Medjahed 8
Signature of a method
The Signature of a method includes the list of arguments with their type and the type returned by the operation
Dr. S. A. Medjahed 9
Association
• Associations are binary. An association can only be named using roles.
Dr. S. A. Medjahed 10
Multiplicity
Each association termination can define the following multiplicities:
• 1: This is the default value for any ending that specifies that there is one and only one
element.
• 0..1: Possibility of having 0 or 1 element.
• 1..*: Possibility of having 1 to n elements.
• 0..*: Possibility of having 0 to n elements.
• n: Sets a specific number of elements.
• n..m: Defines a specific range of elements.
• * : equivalent of 0..*
Dr. S. A. Medjahed 11
Example of multiplicity
Dr. S. A. Medjahed 12
Association attribute
Dr. S. A. Medjahed 13
Reflective association
Dr. S. A. Medjahed 14
Legacy
Dr. S. A. Medjahed 15
Aggregation and Composition
• Aggregation
• Composition
Dr. S. A. Medjahed 16