OOAD - UML - Class and Object Diagrams - Lab

780 views 49 slides May 10, 2020
Slide 1
Slide 1 of 49
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49

About This Presentation

OOAD - UML - Class and Object Diagrams - Lab


Slide Content

Class Diagram
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class and Object Diagrams
Lab Material
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class Diagram
A class diagram shows a set of classes, interfaces, and
collaborations and their relationships.
Class diagrams commonly contain the following things:
Classes
Interfaces
Collaborations
Dependency
Generalization, and
Association relationships
Aggregation
Composition
Multiplicity
3
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class Diagram
A class diagram shows a set of classes, interfaces, and
collaborations and their relationships.
Class diagrams commonly contain the following things:
Classes
Interfaces
Collaborations
Dependency
Generalization, and
Association
Aggregation
Composition
Multiplicity
4
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Steps involved
Study the given problem statement
Identify the classes
Identify the attributes and behaviors (properties and methods)
Denote visibility, data type, argument and return value type
Identify the relationships
Denote Relationships details
Relationship name
Role
Relation direction
Multiplicity
Identify the possible Interface (common mustmethods for set of
classes) and relate
5
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Study the given problem statement
Develop an automated student registration system. The students
registration system identify the School (i.e. Arts & Sciences,
Engineering, Fine Arts, etc.) in which the student is registered. The
school offer both undergraduate and graduate programs. It also shall
Identify the current courses offered by each department and the
instructor engaged to each class to handle the course.
6
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the classes
Develop an automated student registration system. The students
registration system identify the School(i.e. Arts & Sciences,
Engineering, Fine Arts, etc.) in which the studentis registered. The
schooloffer both undergraduate and graduateprograms. It also shall
Identify the current coursesoffered by each departmentand the
instructorengaged to each class to handle the course.
7
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the classes
school
student
undergraduate
graduate
programs
courses
department
instructor
class
course
8
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the attributes and behaviors
Develop an automated student registrationsystem. The students
registration system identify the School (i.e. Arts & Sciences,
Engineering, Fine Arts, etc.) in which the student is registered. The
school offerboth undergraduate and graduate programs. It also shall
Identify the current courses offeredby each department and the
instructor engagedto each class to handlethe course.
9
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the classes
School
-name : String
-address : String
-id : int
-startdate: Date
+school(intid, String name):
+addStudent():bool
+removeStudent(int):bool
name
attributes
operations
10
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Denote visibility, data type…..
1.Public: Any outside classifier can use (+).
2.Protected: Any descendant of the classifier can use (#).
3.Private: Only the classifier itself can use (-).
4.Protected: public within package (~)
1.Instance: Each instance of the classifier holds its own value
for the feature.
2.Class variable: There is just one value of the feature for all
instances of the classifier. (static variable)
static variable should be underlined
* Derived variables should precede /
11
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the relationships
Generalization
Association (general) –name, role, direction, multiplicity
Special types:
Aggregation (parts can exist without whole)
Composition (parts cant exist without whole)
Realization
12
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the relationships
Generalization
Use to show a parent-childrelationship.
Student
……
generalization
+handleClass():void
Graduate student
+attenMidexam():void
Undergraduate student
……
-ug:String
13
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the relationships
GeneralizationShape
SplineEllipsePolygon
Shape
SplineEllipsePolygon
Shared Target Style
Separate Target Style
. . .
. . .
14
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the relationships
Association (general) –name, role, direction, multiplicity
Instructor Course
Teaches
Namean association to describe its nature.
Direction triangle: direction of reading.
Instructor Course
Role:face presented to the other class.
teacher subject taught
Person Company
employee employer
15
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the relationships
Association (general) –name, role, direction, multiplicity
Instructor Course
teacher Subject taught
1..2
0..3
Multiplicity: How manyobjects may be connected across
an instance of an association.
Multiplicity at one end for each object at the other end,
there must be that many objects at the near end.
Exactly one: 1
Zero or one: 0 .. 1
Many: 0 .. *
One or more: 1 .. *
Not shown unspecified or suppressed
16
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the relationships
Aggregation (general) –name, role, direction, multiplicity
1
0..*
Department
Instructor
whole
part
1
1..*
Team
Player
whole
part
17
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the relationships
Composition (general) –name, role, direction, multiplicity
1
0..*
Account
Order
whole
part
1
1..*
School
Department
18
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Identify the possible Interface
Identify one or more classes that
must have a set of common
operations.
Create interface with the set of
common operations (abstract).
Relate the classes and the interface
by Realization.
Defines a set of operation specs
Never defines an implementation
19
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

student registration systemname
address
...
addstudent()
removestudent()
...
School
name
studentID
Student
1..*
*
Graduate UnderGraduate
name
Department
description
Course
name
Instructor
Offers
1
1..*
Attends >
< Teaches
has
1..*1
* * 1..3 1
Assigned To ^
Chair
1
0..1
0..1
Schedule
accepted
20
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example 1
21
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example 2
22
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example 3
23
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example 4
24
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example 5
25
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example 6
26
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Steps involved
Study the given problem statement
Identify the classes
Identify the attributes and behaviors (properties and methods)
Denote visibility, data type, argument and return value type
Identify the relationships
Denote Relationships details
Relationship name
Role
Relation direction
Multiplicity
Identify the possible Interface (common mustmethods for set of
classes) and relate
27
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Object Diagram
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Object Diagram
Object diagrams model the instances of things contained in class
diagrams.
An object diagram shows a set of objects and their relationships
at a point in time.
This involves modeling a snapshot of the system at a moment in
time and rendering a set of objects, their state, and their
relationships.
An object diagram covers a set of instances of the things found in
a class diagram.
29
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Object Representation
In class diagram elements are in abstract form to represent the
blue print and
in object diagram the elements are in concrete form to represent
the real world object.
30
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

How to model Object Diagram
an object diagram is an instance of a class diagram.
It implies that an object diagram consists of instances of things
used in a class diagram.
So both diagrams are made of samebasic elements but in
different form.
To capture a particular system, numbers (classes) of class
diagrams are limited.
However, if we consider object diagrams then we can have
unlimited number of instances, which are unique in nature.
31
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

How to model Object Diagram
a single object diagram cannot capture all the necessary
instances or rather cannot specify all the objects of a system.
Hence, the solution is −
1.First, analyze the system and decide which instances have important
data and association.
2.Second, consider only those instances, which will cover the
functionality.
3.Third, make some optimizationas the number of instances are
unlimited.
32
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Things to be decided
the following things are to be decided before starting the
construction of the diagram,
1.The object diagram should have a meaningful name to indicate its
purpose.
2.The most important elements are to be identified.
3.The association among objects should be clarified.
4.Values of different elements need to be captured to include in the
object diagram.
5.Add proper notes at points where more clarity is required.
33
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class and Object Diagram 1
34
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class and Object Diagram 2
35
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class and Object Diagram 3
36
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class and Object Diagram 4
37
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class and Object Diagram 5
38
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example –Class Diagram
39
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Example –Object Diagram
40
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Lets Try..!
41
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Class vs Object Diagram
42
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

The End
43
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Some Clarifications
44
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Some Clarifications
45
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Some Clarifications
46
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Some Clarifications
47
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

Some Clarifications
48
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam

The End…
49
Dr. P. Victer Paul, Indian Institute of Information Technology Kottayam