Download - #OOP_D_ITS - 8th - Class Diagram
![Page 1: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/1.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 1
C++ OOP :: Class Diagram
![Page 2: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/2.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 2
Classa description of a group of objects with
similar properties, common behavior, and common semantics.
![Page 3: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/3.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 3
Classa template for instantiation of objects
Contains:an attribute (state) section and a method (behavior) section
![Page 4: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/4.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 4
Attributevisibilityopt <<sterotype>>opt name multiplicityopt : typeopt = initial-valueopt {property-string}opt
Example:Tagged value e.g.Author = Kari
E.g. <<unique>>
- (private) only the class can see this attribute# (protected) only the class and all of its subclasses+ (public) all classes that can see the class can also see the attribute
Example: email[1..*] :StringIndicating one or more email addresses.If no email is present you will still have a the empty string (””).If email[0..*] : String is specified, the emailcan be null.
![Page 5: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/5.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 5
visibilityopt <<sterotype>>opt name(parameter-list) multiplicityopt : return-typeopt
{property-string}opt
Method
Examples:+ <<query>> getX() : double+ setX (newX : double)
![Page 6: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/6.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 6
Class Stereotypes
•Manage interactions•Ex: Quiz Scheduler
Control
•Mediate between the system and outside actors •Ex: Quiz Answer
Boundary
•Passive objects•Ex: Quiz Result
Entity
![Page 7: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/7.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 7
Robustness Diagram Rules
![Page 8: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/8.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 8
The Three Most Important Relationships
In Static Modeling
Generalization
Base sub
Class2Class1
Class2Class1
Association
Dependency
![Page 9: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/9.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 9
Generalization
Also called generalization/specialization.
Example: birds are animals, were birds are the most specialized and animals the most general.
![Page 10: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/10.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 10
Generalization used in class diagrams
superclass
subclass subclass
generalization arrow
Animal
Bird
![Page 11: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/11.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 11
Association
A relationship that describes a set of links between classes of objects, indicating some sort of connection between objects of the involved classes.
Example: student follows a course.
you can distinguish between ordinary association, simple aggregation and composition (strong aggregation).
![Page 12: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/12.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 12
Simple Aggregation &
Ordinary AssociationIt seems difficult to give a formal definition of
the distinction between the two concepts.
Ordinary association is used when both of the involved classes are equaly important.
If there is a part-of relation between the involved classes, then aggregation may be adequate. The question of using association or simple aggregation is a conceptual one, it does not say anything about navigation direction and no connection between lifetime is made.
![Page 13: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/13.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 13
Association used in Class Diagram
assembly class
aggregation:
part class part class
class 1 class 2
association:
role-1role-2
class 1 class 2
association:
name
name direction
![Page 14: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/14.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 14
ExampleUniversity
Faculty
Institute Teacherworks for
![Page 15: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/15.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 15
CompositionComposition is a strong type of aggregation indicating that the part object only exist as a part of the assembly class. The part object of an aggregation will be deleted if the assembly object is deleted. An object may be part of only one composite at a time.
assembly class
Composition can be represented in to different ways:
part class
assembly class
part class
![Page 16: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/16.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 16
Example
Window
Client Area1
ScrollBar0..2
Component
Menu
0..1
Input Device* *
Keyboard Mouse
![Page 17: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/17.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 17
Navigability If you have a Quiz-object, the associated Question-objects can be directly reach from the Quiz-object. You will typically find a reference of each object inside the Quiz-object.
Quiz Question* 1..*
Direction of navigation
ordinary association
class Quiz{ // A list of questions Question [] questions;....}
class Question { // no reference to Quiz....}
![Page 18: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/18.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 18
DependencyA dependency relationship indicate that a change in one class may effect the dependent class, but not necessarily the reverse.
You use dependency when you wants to indicate that one thing uses another.
Often used to indicate that a method has object of a class as arguments.
![Page 19: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/19.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 19
Example: Dependency
ActionListener ActionEvent
actionPerformed(ActionEvent e)
![Page 20: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/20.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 20
MultiplicityThe multiplicity is describing the number of participants (classes) involved in an association. For instance an edge in a graph is connecting exactly two vertexes.
A B1
An A is associatedwith exactly one B
An A is associatedwith one or more B
A B1..*
An A is associatedwith zero or more B
A B*
An A is associatedwith zero or one B
A B0..1
![Page 21: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/21.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 21
End of slide show ?
![Page 22: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/22.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 22
For your practice …
![Page 23: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/23.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 23
Ex: undirected graph
Graph
Vertex Edge2 *
*
1
*
1
![Page 24: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/24.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS 24
Ex: information system for
schoolSchool
student Course
Department
teachesInstructor
attends
member
has
assignedTo
chairperson0..1
0..1
1..*
1..*
1..*
1..*
*
* *
1 1..*
*
1..*
1..*
![Page 25: #OOP_D_ITS - 8th - Class Diagram](https://reader035.vdocuments.site/reader035/viewer/2022062405/554f46beb4c905423f8b49a5/html5/thumbnails/25.jpg)
11/04/2023Hadziq Fabroyir - Informatics ITS
☺~ Next: <Template> ~☺
[ 25 ]