You are on page 1of 35

UMLCLASSAND OBJECT DIAGRAM

BY Group
One
STUDENT NAME
WABUSA BOB
DOPIA BRENDA AMAH
BYAMUKAMA ALEX
OVERVIEW
CLASS DIAGRAMS OBJECT DIAGRAMS
• What is a Class Diagram • What is an Object Diagram
• Purpose of Class Diagrams • Purpose of Object Diagrams
• Class Notation • Object Diagram Notations
• Class Visibility • Where to Use Object Diagrams
• Relationships between classes • Class Diagram Vs. Object Diagram
• Where to Use Class Diagrams • How to Draw an Object Diagram
• How to Draw a Class Diagram • Example of an object diagram
• Example
Group
TREY
One
research
2
What is a Class Diagram?
• A class diagram is a type of static structure diagram
that describes the structure of a system by showing the
systems:
 classes, ClassName

 their attributes, attributes

 operations (or methods), operations

 and the relationships among objects


Group
TREY
One
research
3
Purpose of Class Diagrams
1.Shows static structure of classifiers in a system
2.Diagram provides a basic notation for other structure
diagrams prescribed by UML
3.Helpful for developers and other team members too
4.Business Analysts can use class diagrams to model systems
from a business perspective

Group
TREY
One
research
4
Class Notation
A single rectangle is used to
represent the class as shown besides. ClassName
The rectangle is divided into three
attributes
compartments with the topmost
being Class Name, then Attributes operations

in the middle, and Operations at the


bottom.

Group
TREY
One
research
5
Class Notation ….continue
Class Name
ClassName

The name of the class appears in attributes

the first partition


operations
.

Group
TREY
One
research
6
Class Notation ….continue
Class Attributes
Class A

Attributes are shown in the second + Attribute A: type = defaultValue


partition. + Attribute B: type = value B
- Attribute C: type
The attribute type is shown after
the colon.
Attributes map onto member
variables (data members) in code.
Group
TREY
One
research
7
Class Notation ….continue
Class Operations (Methods) Class A

+ Attribute A: type = defaultValue


+ Attribute B: type = value B
Operations are shown in the third partition. They are - Attribute C: type
services the class provides.
The return type of a method is shown after the
colon at the end of the method signature.
+ Operation A(params) : return
The return type of method parameters is shown + Operation B() : void
after the colon following the parameter name. - Operation C() : void
The return type of method parameters are shown
after the colon following the parameter name.
Operations map onto class methods in code
Group
TREY
One
research
8
Class Visibility
Class A

+ name : String
+ denotes public attributes or operations # address : Address
# birthdate : Date
- denotes private attributes or operations / age : Date
- ssn : Id
# denotes protected attributes or
operations
/ denotesderived
~ denotes a package
Group
TREY
One
research
9
Relationships between classes

Classes are interrelated to each


other in specific ways. In
particular, relationships in class
diagrams include different types
of logical connections.

Group
TREY
One
research
10
Inheritance (or Generalization):

• It refers to a type of relationship wherein one associated class is a child of


another by virtue of assuming the same functionalities of the parent class.
The child class is a specific type of parent class. To show inheritance in a
UML diagram, a solid line from the child class to the parent class is drawn
using an unfilled arrowhead.

• The figure below shows an example of inheritance hierarchy. SubClass1


and SubClass2 are derived from SuperClass. The relationship is displayed as
a solid line with a hollow arrowhead that points from the child element to the
parent element.

Group
TREY
One
research
11
Inheritance (or Generalization):

• It refers to a type of relationship wherein one associated class is a child of


another by virtue of assuming the same functionalities of the parent class.
The child class is a specific type of parent class. To show inheritance in a
UML diagram, a solid line from the child class to the parent class is drawn
using an unfilled arrowhead.

• The figure below shows an example of inheritance hierarchy. SubClass1


and SubClass2 are derived from SuperClass. The relationship is displayed as
a solid line with a hollow arrowhead that points from the child element to the
parent element.

Group
TREY
One
research
12
Association
• Associations are relationships between classes in a UML Class Diagram.
Associations are typically named using a verb or verb phrase which reflects
the real world problem domain. They are represented by a solid line between
classes.
• Associations are further divided into four types: uni-directional, bi-
directional, aggregation, and composition association.

Group
TREY
One
research
13
Unidirectional Association

• Also called the directed association, this type of association refers to when
an object contains another object in its field. This relationship signifies the
flow of information between two classifiers. The association is represented by
a solid line and an arrow pointing towards the container classifier. The
arrowhead depicts a container-contained directional flow.

Group
TREY
One
research
14
Bi-directional Association

• This association is used when two classifiers are linked closely and
can store each other in their fields. A solid line represents the
association. The bi-directional association is the most common type
of association used in UML diagrams.

Group
TREY
One
research
15
Aggregation

• Aggregation is a more specific type of association and shows the ‘part-of’ relationship in
diagrams. However, this type can only link two classifiers and must have a binary
association. In UML diagrams, it is represented by a solid line and a hollow diamond near
the containing class.
• In aggregation, 2 classes have a whole-part relationship. For example, if an employee
does not come, the organization will remain there.

Group
TREY
One
research
16
Composition

• This type of relationship is used to represent the dependence of objects on the focal entity.
The focal classifier contains objects, but the contained objects are also deleted if the focal
class is deleted. The composition relationships are represented by a solid line and a filled
diamond shape drawn near the containing class.
• In composition, a class is strongly connected to another class that it will stop functioning
without it. For example, if an organization closes, all employees will have to leave

Group
TREY
One
research
17
Multiplicity

Group
TREY
One
research
18
Dependency
• This is a weaker relationship type used when an object is not contained in
any field.
• Dependency shows that one class depends on another. Change in one class
will create change in another class. For example, an employee is dependent on
the organization.
• It is represented by a dashed line and an arrowhead pointing towards the
dependent entity.

Group
TREY
One
research
19
Where to Use Class Diagrams
 Describing the static view of the system.
 Showing the collaboration among the elements of the static
view.
 Describing the functionalities performed by the system.
 Construction of software applications using object oriented
languages.

Group
TREY
One
research
20
How to Draw a Class Diagram?
• The following points should be remembered while drawing a class diagram −
 The name of the class diagram should be meaningful to describe the aspect of the
system.
 Each element and their relationships should be identified in advance.
 Responsibility (attributes and methods) of each class should be clearly identified
 For each class, minimum number of properties should be specified, as unnecessary
properties will make the diagram complicated.
 Use notes whenever required to describe some aspect of the diagram. At the end of the
drawing it should be understandable to the developer/coder.
 Finally, before making the final version, the diagram should be drawn on plain paper and
reworked as many times as possible to make it correct.

Group
TREY
One
research
21
Example
• The following diagram is an example of an Order System of an application. It describes a particular aspect of the entire
application.
• First of all, Order and Customer are identified as the two elements of the system. They have a one-to-many relationship
because a customer can have multiple orders.
• Order class is an abstract class and it has two concrete classes (inheritance relationship) SpecialOrder and
NormalOrder.
• The two inherited classes have all the properties as the Order class. In addition, they have additional functions like
dispatch () and receive ().
• The following class diagram has been drawn considering all the points mentioned above.

Group
TREY
One
research
22
Example

Group
TREY
One
research
23
OBJECT DIAGRAMS
What is an Object Diagram?
• An object is an instance of a class at a particular runtime moment with its state and data
values. Similarly, an object diagram is an instance of a class diagram. Object diagrams are
also known as instance diagrams.
Object Name
• The object diagram depicts the behavioral relationships among class instances during a
point in time. This captures dynamic as well as runtime state and modification of the
program. It incorporates data values of entities or attributes inside the structure. attributes

• An object diagram is an overview of the objects in a program during a particular moment


in time, such as the relations together. Object diagrams are used whenever you need to
observe and determine the values of attributes and conditions of the object at distinct phases.
This can happen at any time throughout the application's performance.

Group
TREY
One
research
24
Purpose of Object Diagrams
 It can be used as a support in forward and reverse engineering.
 Object relationships of a system can be easily demonstrated by an object diagram.
 A static view of interaction is also very clear using the object diagram.
 A programmer can use an object diagram to understand object behavior and their relationship from a practical
perspective during the execution time.
 Object diagrams are used to generate a blueprint of an object-oriented system.
 Object diagrams model the classes, data, and other attributes as a set or a single unit.
 It is used for the analysis of online and offline systems. The functioning of a system can be properly visualized using
object diagrams.

Group
TREY
One
research
25
Object Diagram Notations
• Object name. Every object is symbolized by a
rectangle. It shows the object name in the top row
of the rectangle along with its class underlined and
divided by a colon.
• Object attributes. Object attributes can be listed
in the rectangle in the bottom row. However, unlike
classes, object attributes must have values assigned
to them at that particular instance of runtime.
• Links. The purpose of links in a UML object
diagram is to show relationships of the objects with
each other. They show association, composition,
aggregation and inheritance.

Group
TREY
One
research
26
Where to Use Object Diagrams?
 Making the prototype of a
system.
 Reverse engineering.
 Modeling complex data
structures.
 Understanding the system from
practical perspective

Group
TREY
One
research
27
How to Draw an Object Diagram?

To capture a particular system, numbers of class diagrams are limited. However, if we consider object
diagrams then we can have unlimited number of instances, which are unique in nature. Only those instances
are considered, which have an impact on the system.
From the above discussion, it is clear that a single object diagram cannot capture all the necessary instances or
rather cannot specify all the objects of a system. Hence, the solution is −
 First, analyze the system and decide which instances have important data and association.
 Second, consider only those instances, which will cover the functionality.
 Third, make some optimization as the number of instances are unlimited.

Group
TREY
One
research
28
How to Draw an Object Diagram …cnts
Before drawing an object diagram, the following things should be remembered and understood clearly −
Object diagrams consist of objects.
The link in object diagram is used to connect objects.
Objects and links are the two elements used to construct an object diagram.
 After this, the following things are to be decided before starting the construction of the diagram
 The object diagram should have a meaningful name to indicate its purpose.
 The most important elements are to be identified.
 The association among objects should be clarified.
 Values of different elements need to be captured to include in the object diagram.
 Add proper notes at points where more clarity is required.

Group
TREY
One
research
29
Example of an object diagram
Before drawing an object diagram, the following things should be remembered and understood clearly −
Object diagrams consist of objects.
The link in object diagram is used to connect objects.
Objects and links are the two elements used to construct an object diagram.
 After this, the following things are to be decided before starting the construction of the diagram
 The object diagram should have a meaningful name to indicate its purpose.
 The most important elements are to be identified.
 The association among objects should be clarified.
 Values of different elements need to be captured to include in the object diagram.
 Add proper notes at points where more clarity is required.

Group
TREY
One
research
30
Example of an object diagram

Group
TREY
One
research
31
Class Diagram Vs. Object Diagram
Class Diagram Object Diagram
It represents static aspects of a It represents the behavior of a
system system in real time
It doesn’t include dynamic It captures runtime changes of a
changes system
It includes attributes of an It includes data values of any
instance instance.
Class Diagram manipulates the Objects are instances of classes
behavior of objects

Group
TREY
One
research
32
Summary
 Object diagram groups together things that share similar behavior.
 A class diagram represents a bird’s eye view of a system, i.e., an abstraction
which is an object-oriented programming concept.
 An object diagram represents a static view of an object-oriented system.
 One class can refer to multiple classes.
 A single class can have any number of objects.
 Objects are related to one another because they share the same class.
 The object of different classes can also be connected.

Group
TREY
One
research
33
Q&A
ThankYou

Group
TREY
One
research
34
Useful Links
https://www.edrawsoft.com/example-uml-class-diagram.html
https://www.edrawsoft.com/class-diagram.html

https://creately.com/blog/diagrams/class-diagram-relationships/
https://www.tutorialspoint.com/uml/uml_class_diagram.htm
https://www.lucidchart.com/pages/uml-object-diagram

TREY
research
35

You might also like