SlideShare a Scribd company logo
Class
Diagram
OUM SAOKOSAL
Chief of Faculty of Computer Science, NPIC.edu.kh
Master of Engineering in Information Systems,
Jeonju University, South Korea
012252752 / 070252752
https://youtube.com/oumsaokosal
http://kosalgeek.com
Class Diagram
 A class is a description of a set of
objects that share the same attributes,
operations, relationships, and semantics.
 Graphically, a class is rendered as a
rectangle, usually including its name,
attributes, and operations in separate,
designated compartments.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 2
ClassName
attributes
operations
Class Diagram (cont.)
 Attributes/Operation can be:
+ public
# protected
- private
~ default
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 3
Person
+ name : String
# address : Address
# birthdate : Date
~ ssn : Integer
eat(f:Food) : Void
sleep(t:Time) : Duration
work() : Void
play(sport) : Boolean
Depicting Classes
 When drawing a class, you needn’t show attributes and operation
in every diagram.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 4
Person
name : String
birthdate : Date
ssn : Int
eat()
sleep()
work()
play()
Person
Person
name
address
birthdate
Person
eat
play
Person
Dependency Relationships
 A dependency indicates a semantic relationship between two or
more elements. The dependency from CourseSchedule to Course
exists because Course is used in both the add and remove
operations of CourseSchedule.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 5
CourseSchedule
add(c : Course)
remove(c : Course)
Course
Generalization Relationships
 A generalization connects a subclass to its superclass. It denotes
an inheritance of attributes and behavior from the superclass to
the subclass and indicates a specialization in the subclass of the
more general superclass.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 6
Person
Student Teacher
Association Relationships
 If two classes in a model need to communicate with each other,
there must be link between them.
 An association denotes that link.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 7
InstructorStudent
Association Relationships (Cont.)
 We can indicate the multiplicity of an association by adding
multiplicity adornments to the line denoting the association.
 The example indicates that a Student has one or more Instructors:
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 8
InstructorStudent
1..*
Association Relationships (Cont.)
 The example indicates that every Instructor has one or more
Students:
 We can also indicate the behavior of an object in an association
(i.e., the role of an object) using rolenames.
 We can also name the association.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 9
InstructorStudent
1..*
InstructorStudent
1..*1..*
learns fromteaches
TeamStudent
membership
1..* 1..*
Association Relationships (Cont.)
 We can constrain the association relationship by defining the
navigability of the association. Here, a Router object requests
services from a DNS object by sending messages to (invoking the
operations of) the server. The direction of the association
indicates that the server has no knowledge of the Router.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 10
Router DomainNameServer
Association Relationships:
Aggregations and Compositions
 We can model objects that contain other objects by way of
special associations called aggregations and compositions.
 An aggregation specifies a whole-part relationship between an
aggregate (a whole) and a constituent part, where the part can
exist independently from the aggregate. Aggregations are
denoted by a hollow-diamond adornment on the association.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 11
Car
Engine
Transmission
Association Relationships:
Aggregations and Compositions (cont.)
 A composition indicates a strong ownership and coincident
lifetime of parts by the whole (i.e., they live and die as a whole).
Compositions are denoted by a filled-diamond adornment on the
association.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 12
Window
Scrollbar
Titlebar
Menu
1
1
1
1
1
1 .. *
Interfaces
 An interface is a named set of operations that specifies the
behavior of objects without showing their inner structure. It can
be rendered in the model by a one- or two-compartment
rectangle, with the stereotype <<interface>> above the interface
name.
 Interfaces do not get instantiated. They have no attributes or
state. Rather, they specify the services offered by a related class.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 13
<<interface>>
ControlPanel
getChoices : Choice[]
makeChoice (c : Choice)
getSelection : Selection
Interface Realization Relationship
 A realization relationship connects a class with an interface that
supplies its behavioral specification. It is rendered by a dashed
line with a hollow triangle towards the specifier.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 14
<<interface>>
ControlPanel
VendingMachine
specifier
implementation
Depicting Interfaces
 A class’interface can also be rendered by a circle connected to a
class by a solid line.
This presentation is available to download at: https://www.slideshare.net/oumsaokosal 15
File
outputStream
FileWriter
{file must not be locked}
FileReader
{file must exist}

More Related Content

PDF
Java OOP Programming language (Part 6) - Abstract Class & Interface
PPT
Abstract class
PDF
What are Abstract Classes in Java | Edureka
PPT
Chapter 9 Interface
PDF
javainterface
PPT
Java interface
PPT
Java Programming - Abstract Class and Interface
PPT
Interface in java By Dheeraj Kumar Singh
Java OOP Programming language (Part 6) - Abstract Class & Interface
Abstract class
What are Abstract Classes in Java | Edureka
Chapter 9 Interface
javainterface
Java interface
Java Programming - Abstract Class and Interface
Interface in java By Dheeraj Kumar Singh

What's hot (20)

PPTX
Java abstract class & abstract methods
PPTX
Interface in java ,multiple inheritance in java, interface implementation
PDF
8 abstract classes and interfaces
PPTX
Java interfaces
PPTX
Abstraction in java [abstract classes and Interfaces
PPT
Abstract class in java
PPTX
Abstract Class Presentation
PPTX
Abstract Class & Abstract Method in Core Java
PPTX
Abstract class and Interface
PPT
Java interfaces & abstract classes
PPT
PPTX
Java OOPS Concept
PPTX
PPTX
Abstract class and interface
PPTX
Lecture 1 uml with java implementation
PDF
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
PPTX
Interfaces in java
PDF
Abstraction
PPT
06 abstract-classes
Java abstract class & abstract methods
Interface in java ,multiple inheritance in java, interface implementation
8 abstract classes and interfaces
Java interfaces
Abstraction in java [abstract classes and Interfaces
Abstract class in java
Abstract Class Presentation
Abstract Class & Abstract Method in Core Java
Abstract class and Interface
Java interfaces & abstract classes
Java OOPS Concept
Abstract class and interface
Lecture 1 uml with java implementation
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
Interfaces in java
Abstraction
06 abstract-classes
Ad

Similar to Class Diagram | OOP and Design Patterns by Oum Saokosal (20)

PPT
PDF
2 class use case
PDF
Introduction to UML, a guide to learn.pdf
PPT
Uml - An Overview
PPT
08 class and sequence diagrams
PDF
UML Overview and Introduction functions.pdf
PPT
Chapter3
PPT
Uml report
PPT
Uml class diagram and packages ppt for dot net
PPTX
Unified Modeling Language and Examples .pptx
PPT
Descriptions of class diagrams in software
PPT
Object oriented programming in C++ programming language
PPT
Introduction to software engineering in data science.ppt
PPT
Object oriented programming language in software engineering
PPT
An Evolution of UML projects.and also what is project
PPT
Lecture12 software design class diagram
PPT
Chapter 2-Unified Modeling Languagee.ppt
PPT
Chapter 2-Unified Modeling Languagee.ppt
PPT
Fundamentals of Software Engineering
2 class use case
Introduction to UML, a guide to learn.pdf
Uml - An Overview
08 class and sequence diagrams
UML Overview and Introduction functions.pdf
Chapter3
Uml report
Uml class diagram and packages ppt for dot net
Unified Modeling Language and Examples .pptx
Descriptions of class diagrams in software
Object oriented programming in C++ programming language
Introduction to software engineering in data science.ppt
Object oriented programming language in software engineering
An Evolution of UML projects.and also what is project
Lecture12 software design class diagram
Chapter 2-Unified Modeling Languagee.ppt
Chapter 2-Unified Modeling Languagee.ppt
Fundamentals of Software Engineering
Ad

More from OUM SAOKOSAL (20)

PPTX
Android app development - Java Programming for Android
PDF
Java OOP Programming language (Part 8) - Java Database JDBC
PDF
Java OOP Programming language (Part 7) - Swing
PDF
Java OOP Programming language (Part 5) - Inheritance
PDF
Java OOP Programming language (Part 4) - Collection
PDF
Java OOP Programming language (Part 3) - Class and Object
PDF
Java OOP Programming language (Part 1) - Introduction to Java
PDF
Javascript & DOM - Part 1- Javascript Tutorial for Beginners with Examples
PDF
Aggregate rank bringing order to web sites
DOC
How to succeed in graduate school
PDF
Google
PDF
E miner
PDF
Data preparation for mining world wide web browsing patterns (1999)
PDF
Consumer acceptance of online banking an extension of the technology accepta...
DOCX
When Do People Help
DOC
Mc Nemar
DOCX
Correlation Example
DOC
Sem Ski Amos
PPT
Sem+Essentials
DOC
Path Spss Amos (1)
Android app development - Java Programming for Android
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 7) - Swing
Java OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 4) - Collection
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 1) - Introduction to Java
Javascript & DOM - Part 1- Javascript Tutorial for Beginners with Examples
Aggregate rank bringing order to web sites
How to succeed in graduate school
Google
E miner
Data preparation for mining world wide web browsing patterns (1999)
Consumer acceptance of online banking an extension of the technology accepta...
When Do People Help
Mc Nemar
Correlation Example
Sem Ski Amos
Sem+Essentials
Path Spss Amos (1)

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Landforms and landscapes data surprise preview
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
Software Engineering BSC DS UNIT 1 .pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Congenital Hypothyroidism pptx
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
human mycosis Human fungal infections are called human mycosis..pptx
Open Quiz Monsoon Mind Game Prelims.pptx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Landforms and landscapes data surprise preview
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
O7-L3 Supply Chain Operations - ICLT Program
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
Open Quiz Monsoon Mind Game Final Set.pptx
Insiders guide to clinical Medicine.pdf
Introduction and Scope of Bichemistry.pptx
Software Engineering BSC DS UNIT 1 .pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Congenital Hypothyroidism pptx
UPPER GASTRO INTESTINAL DISORDER.docx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharmacology of Heart Failure /Pharmacotherapy of CHF
NOI Hackathon - Summer Edition - GreenThumber.pptx
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
Revamp in MTO Odoo 18 Inventory - Odoo Slides

Class Diagram | OOP and Design Patterns by Oum Saokosal

  • 1. Class Diagram OUM SAOKOSAL Chief of Faculty of Computer Science, NPIC.edu.kh Master of Engineering in Information Systems, Jeonju University, South Korea 012252752 / 070252752 https://youtube.com/oumsaokosal http://kosalgeek.com
  • 2. Class Diagram  A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics.  Graphically, a class is rendered as a rectangle, usually including its name, attributes, and operations in separate, designated compartments. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 2 ClassName attributes operations
  • 3. Class Diagram (cont.)  Attributes/Operation can be: + public # protected - private ~ default This presentation is available to download at: https://www.slideshare.net/oumsaokosal 3 Person + name : String # address : Address # birthdate : Date ~ ssn : Integer eat(f:Food) : Void sleep(t:Time) : Duration work() : Void play(sport) : Boolean
  • 4. Depicting Classes  When drawing a class, you needn’t show attributes and operation in every diagram. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 4 Person name : String birthdate : Date ssn : Int eat() sleep() work() play() Person Person name address birthdate Person eat play Person
  • 5. Dependency Relationships  A dependency indicates a semantic relationship between two or more elements. The dependency from CourseSchedule to Course exists because Course is used in both the add and remove operations of CourseSchedule. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 5 CourseSchedule add(c : Course) remove(c : Course) Course
  • 6. Generalization Relationships  A generalization connects a subclass to its superclass. It denotes an inheritance of attributes and behavior from the superclass to the subclass and indicates a specialization in the subclass of the more general superclass. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 6 Person Student Teacher
  • 7. Association Relationships  If two classes in a model need to communicate with each other, there must be link between them.  An association denotes that link. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 7 InstructorStudent
  • 8. Association Relationships (Cont.)  We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association.  The example indicates that a Student has one or more Instructors: This presentation is available to download at: https://www.slideshare.net/oumsaokosal 8 InstructorStudent 1..*
  • 9. Association Relationships (Cont.)  The example indicates that every Instructor has one or more Students:  We can also indicate the behavior of an object in an association (i.e., the role of an object) using rolenames.  We can also name the association. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 9 InstructorStudent 1..* InstructorStudent 1..*1..* learns fromteaches TeamStudent membership 1..* 1..*
  • 10. Association Relationships (Cont.)  We can constrain the association relationship by defining the navigability of the association. Here, a Router object requests services from a DNS object by sending messages to (invoking the operations of) the server. The direction of the association indicates that the server has no knowledge of the Router. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 10 Router DomainNameServer
  • 11. Association Relationships: Aggregations and Compositions  We can model objects that contain other objects by way of special associations called aggregations and compositions.  An aggregation specifies a whole-part relationship between an aggregate (a whole) and a constituent part, where the part can exist independently from the aggregate. Aggregations are denoted by a hollow-diamond adornment on the association. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 11 Car Engine Transmission
  • 12. Association Relationships: Aggregations and Compositions (cont.)  A composition indicates a strong ownership and coincident lifetime of parts by the whole (i.e., they live and die as a whole). Compositions are denoted by a filled-diamond adornment on the association. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 12 Window Scrollbar Titlebar Menu 1 1 1 1 1 1 .. *
  • 13. Interfaces  An interface is a named set of operations that specifies the behavior of objects without showing their inner structure. It can be rendered in the model by a one- or two-compartment rectangle, with the stereotype <<interface>> above the interface name.  Interfaces do not get instantiated. They have no attributes or state. Rather, they specify the services offered by a related class. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 13 <<interface>> ControlPanel getChoices : Choice[] makeChoice (c : Choice) getSelection : Selection
  • 14. Interface Realization Relationship  A realization relationship connects a class with an interface that supplies its behavioral specification. It is rendered by a dashed line with a hollow triangle towards the specifier. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 14 <<interface>> ControlPanel VendingMachine specifier implementation
  • 15. Depicting Interfaces  A class’interface can also be rendered by a circle connected to a class by a solid line. This presentation is available to download at: https://www.slideshare.net/oumsaokosal 15 File outputStream FileWriter {file must not be locked} FileReader {file must exist}