SlideShare a Scribd company logo
© Dr. Khalid Nazim S.A. B.E., M. Tech, MBA[IT], PhD, LMISTE, LMCSI, MIE
Associate Professor,
Department of Computer Science & Information,
Majmaah University, Az- Zulfi Campus, KSA.
CS 413: Software Modeling and Analysis
Week 13
Topics to be Discussed:
 What are class Diagrams?
 What is a class?
 CRC(Class, Responsibility, Collaborator)
 UML Class Diagram Notation
 How to draw Class Diagrams
 Relationships between classes
 Purpose of Class Diagrams
 Benefits of Class Diagrams
 Simple Examples
Class diagram and its importance in software
Design Phase
Design : specifying the structure of how a
software system will be written and function,
without writing the complete implementation.
A transition from "what" the system must do,
to "how" the system will do it
1. What classes will we need to implement a
system that meets our requirements?
2. What fields and methods will each class
have?
3. How will the classes interact with each
other?
Customer
Account
Opens account
Knows name
Knows address
Account
Manager
Knows interest rate
Knows balance
Handles deposits
Reports fraud to
manager
CRC (Class responsibility collaborator)
 A Class-Responsibility-Collaboration
(CRC) card is a structured tool used in
object-oriented software design.
 It captures essential information about a
class, including its name, responsibilities,
and collaborations with other classes.
 CRC cards facilitate collaborative
discussions among team members and help
in refining the design of software systems.
UML Class Diagrams
What is a UML class diagram?
UML class diagram: a picture of
The classes in an OO system,
Their fields and methods,
Connections between the classes
that interact or inherit from each
other,
Algorithmic details; how a
particular behavior is implemented.
Class Diagrams
Class diagrams are used when developing an object-oriented system
model to show the classes in a system and the associations between
these classes.
An object class can be thought of as a general definition of one kind of
system object.
An association is a link between classes that indicates that there is
some relationship between these classes.
When you are developing models during the early stages of the
software engineering process, objects represent something in the real
world, such as a patient, a prescription, doctor, etc.
UML Notation for Classes
ClassName
The top compartment shows the class
name.
field1
…
fieldn
The middle compartment contains the
declarations of the fields of the class.
method1
…
methodm
The bottom compartment contains the
declarations of the methods
How to Draw Class Diagrams
Drawing class diagrams involves visualizing the structure of a system, including classes, their attributes,
methods, and relationships.
Step 1: Identify Classes:
1. Start by identifying the classes in the system.
2. A class represents a blueprint for objects and should encapsulate related attributes and methods.
Step 2: List Attributes and Methods:
1. For each class, list its attributes (properties, fields) and methods (functions, operations).
2. Include information such as data types and visibility (public, private, protected).
Step 3: Identify Relationships:
1. Determine the relationships between classes.
2. Common relationships include associations, aggregations, compositions, inheritance, and
dependencies.
3. Understand the nature and multiplicity of these relationships.
Step 4: Create Class Boxes:
1. Draw a rectangle (class box) for each class identified.
2. Place the class name in the top compartment of the box.
3. Divide the box into compartments for attributes and methods.
Step 5: Add Attributes and Methods:
1. Inside each class box, list the attributes and methods in their respective compartments.
2. Use visibility notations (+ for public, – for private, # for protected, ~ for package/default).
Step 6: Draw Relationships:
1. Draw lines to represent relationships between classes.
2. Use arrows to indicate the direction of associations or dependencies.
3. Different line types or notations may be used for various relationships.
Step 7: Label Relationships:
1. Label the relationships with multiplicity and role names if needed.
2. Multiplicity indicates the number of instances involved in the relationship, and role names clarify the
role of each class in the relationship.
Step 8: Review and Refine:
1. Review the class diagram to ensure it accurately represents the system’s structure and relationships.
2. Refine the diagram as needed based on feedback and requirements.
How to Draw Class Diagrams
Class attributes
attributes (fields, instance variables)
visibility name : type [count] = default_value
1. visibility: + public
# protected
- private
~ package (default)
/ derived
2. underline static attributes
3. Derived attribute: not stored, but can
be computed from other attribute values
4. attribute example:
- balance : double = 0.00
Class Operations / Methods
operations / methods
visibility name (parameters) : return_type
1. visibility: + public
# protected
- private
~ package (default)
2. underline static methods
3. parameter types listed as (name: type)
4. omit return_type on constructors and
when return type is void
5. method example:
+ distance(p1: Point, p2: Point): double
Comments
represented as a folded note, attached to the appropriate class / method /
etc. by a dashed line
Class diagram and its importance in software
Relationships between classes
Generalization :
An inheritance relationship,
1. Inheritance between classes
2. Interface implementation
Association :
A usage relationship
1. Dependency
2. Aggregation
3. Composition
Generalization Relationships
Generalization (inheritance) relationships
1. hierarchies drawn top-down with arrows
pointing upward to parent
2. line/arrow styles differ, based on
whether parent is a(n):
1. class: solid line, black arrow
2. abstract class: solid line, white
arrow
3. interface: dashed line, white arrow
Associational Relationships
Associational (usage) relationships
1. Multiplicity : (how many are used)
* ⇒ 0, 1, or more
1 ⇒ 1 exactly
2..4 ⇒ between 2 and 4, inclusive
3..* ⇒ 3 or more
2. Name : (what relationship the objects have)
3. Navigability : (direction)
 one-to-one
each student must carry exactly one ID card
 one-to-many
one rectangle list can contain many rectangles
Multiplicity of Associations
Association Types
1. aggregation: "is part of"
 symbolized by a clear white
diamond.
2. composition: "is entirely made of"
 stronger version of aggregation
the parts live and die with the whole.
 symbolized by a black diamond.
3. dependency: "uses temporarily"
 symbolized by dotted line
 often is an implementation
detail, not an intrinsic part of
that object's state
1
1
Car
aggregation
Engine
Lottery
Ticket
Random
dependency
Page
Book
composition
*
1
Purpose of Class Diagrams
The main purpose of using class diagrams is:
1. This is the only UML that can
appropriately depict various aspects of
the OOPs concept.
2. Proper design and analysis of
applications can be faster and efficient.
3. It is the base for deployment and
component diagram.
4. It incorporates forward and reverse
engineering.
Benefits of Class Diagrams
1. Clarity and Communication
2. Standardization
3. Facilitates Object-Oriented Design
4. Documentation and Maintenance
5. Support for Code Generation
Class Diagram : Simple Example
Class Diagram
Example: 01
Aggregation –
Order class contains
OrderDetail classes.
No arrows; info can flow
in both directions
Class Diagram
Example: 02
DVD Movie VHS Movie Video Game
Rental Item
Rental Invoice
1..*
1
Customer
Checkout Screen
0..1
1
Simple
Association
Class
Abstract
Class
Simple
Aggregation
Generalization
Composition
Multiplicity
Class Diagram
Example: 03: Video Store
Class diagram and its importance in software
 Structural UML diagram provide a visual language for representing the static structure of a
system, offering clarity and facilitating communication through class diagrams, object
diagrams, package diagrams, and more.
 These diagrams offer insights into the relationships, dependencies, and organization of
elements within a software system.
 UML Class Diagrams are a powerful tool in software engineering, offering significant
advantages in clarity, standardization, and support for object-oriented design.
 However, it is essential to be aware of their limitations and use them in conjunction with other
modeling techniques to achieve a comprehensive understanding of the system.
Summary
Class diagram and its importance in software

More Related Content

PDF
Software Testing and UML Lab
Harsh Kishore Mishra
 
PPTX
SMD Unit ii
madhavi patil
 
PPT
Uml - An Overview
Raj Thilak S
 
PPTX
UNIT II STATIC UML DIAGRAMS.pptx
anguraju1
 
PDF
Object oriented analysis and design unit- iv
Shri Shankaracharya College, Bhilai,Junwani
 
PPTX
Uml
Vishwa Mohan
 
PDF
Introduction to UML
yndaravind
 
DOCX
Chapterunifiedmo 3 UML Class Diagram.docx
MohammedNouh7
 
Software Testing and UML Lab
Harsh Kishore Mishra
 
SMD Unit ii
madhavi patil
 
Uml - An Overview
Raj Thilak S
 
UNIT II STATIC UML DIAGRAMS.pptx
anguraju1
 
Object oriented analysis and design unit- iv
Shri Shankaracharya College, Bhilai,Junwani
 
Introduction to UML
yndaravind
 
Chapterunifiedmo 3 UML Class Diagram.docx
MohammedNouh7
 

Similar to Class diagram and its importance in software (20)

PPT
Intro Uml
Kris der Rose
 
PPT
Object Oriented Modeling and Design with UML
Malek Sumaiya
 
PPT
CASE Tools lab.ppt
RAJESH S
 
PPTX
Architecture and design
himanshu_airon
 
PPTX
Requirements modeling
AnanthiP8
 
PPTX
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
leela rani
 
PPT
Chapter 2-Unified Modeling Languagee.ppt
SisayNegash4
 
PPT
Chapter 2-Unified Modeling Languagee.ppt
SisayNegash4
 
PPT
Object Oriented Design
Sudarsun Santhiappan
 
PPT
Object Oriented Design
Aravinth NSP
 
PDF
CS8592 Object Oriented Analysis & Design - UNIT II
pkaviya
 
PPTX
class diagram
Shohan Ean
 
DOCX
Ooad unit 1
raj kumar
 
PPT
SDA ClassDiagram.ppt
AteeqaKokab1
 
PPTX
OOP_Module 2.pptx
PrasenjitKumarDas2
 
PPT
Week 10-classdiagrams.pptdddddddddddddddddddddddddddd
v67904413
 
PPTX
UML Design Document Training Learn UML .pptx
raghavanp4
 
PPT
Fundamentals of Software Engineering
Madhar Khan Pathan
 
PPT
ObjectOrientedSystems.ppt
ChishaleFriday
 
PPTX
3_ObjectOrientedSystems.pptx
RokaKaram
 
Intro Uml
Kris der Rose
 
Object Oriented Modeling and Design with UML
Malek Sumaiya
 
CASE Tools lab.ppt
RAJESH S
 
Architecture and design
himanshu_airon
 
Requirements modeling
AnanthiP8
 
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
leela rani
 
Chapter 2-Unified Modeling Languagee.ppt
SisayNegash4
 
Chapter 2-Unified Modeling Languagee.ppt
SisayNegash4
 
Object Oriented Design
Sudarsun Santhiappan
 
Object Oriented Design
Aravinth NSP
 
CS8592 Object Oriented Analysis & Design - UNIT II
pkaviya
 
class diagram
Shohan Ean
 
Ooad unit 1
raj kumar
 
SDA ClassDiagram.ppt
AteeqaKokab1
 
OOP_Module 2.pptx
PrasenjitKumarDas2
 
Week 10-classdiagrams.pptdddddddddddddddddddddddddddd
v67904413
 
UML Design Document Training Learn UML .pptx
raghavanp4
 
Fundamentals of Software Engineering
Madhar Khan Pathan
 
ObjectOrientedSystems.ppt
ChishaleFriday
 
3_ObjectOrientedSystems.pptx
RokaKaram
 
Ad

More from nazimsattar (20)

PPTX
how to build a simple operating system type
nazimsattar
 
PPTX
operating system Evolution understanding the basics
nazimsattar
 
PPT
working with internet technologies using XML
nazimsattar
 
PPT
working with internet technologies using CSS
nazimsattar
 
PPT
different Data_Analysis concepts in data science
nazimsattar
 
PPT
Data Munging in concepts of data mining in DS
nazimsattar
 
PDF
GRASP_Designing Objects With Responsibilities.pdf
nazimsattar
 
PPT
Memory management principles in operating systems
nazimsattar
 
PPT
Deadlock principles in operating systems
nazimsattar
 
PDF
overview of natural language processing concepts
nazimsattar
 
PDF
introduction to natural language processing
nazimsattar
 
PPT
HCI_usable_user_interface_productivity in HCI
nazimsattar
 
PPT
HCI_user_interaction_Design_interaction design
nazimsattar
 
PPT
Introduction to the operating and its types
nazimsattar
 
PPT
Operating systems structures and their practical applications
nazimsattar
 
PPT
Block_Chain_Technology and its concepts in reality
nazimsattar
 
PPT
Edge Computing and its related technologies
nazimsattar
 
PPTX
The Real time applications of Virtual Reality
nazimsattar
 
PPTX
Marketing of AI technology in real life examples
nazimsattar
 
PPT
system analysis and design used in software
nazimsattar
 
how to build a simple operating system type
nazimsattar
 
operating system Evolution understanding the basics
nazimsattar
 
working with internet technologies using XML
nazimsattar
 
working with internet technologies using CSS
nazimsattar
 
different Data_Analysis concepts in data science
nazimsattar
 
Data Munging in concepts of data mining in DS
nazimsattar
 
GRASP_Designing Objects With Responsibilities.pdf
nazimsattar
 
Memory management principles in operating systems
nazimsattar
 
Deadlock principles in operating systems
nazimsattar
 
overview of natural language processing concepts
nazimsattar
 
introduction to natural language processing
nazimsattar
 
HCI_usable_user_interface_productivity in HCI
nazimsattar
 
HCI_user_interaction_Design_interaction design
nazimsattar
 
Introduction to the operating and its types
nazimsattar
 
Operating systems structures and their practical applications
nazimsattar
 
Block_Chain_Technology and its concepts in reality
nazimsattar
 
Edge Computing and its related technologies
nazimsattar
 
The Real time applications of Virtual Reality
nazimsattar
 
Marketing of AI technology in real life examples
nazimsattar
 
system analysis and design used in software
nazimsattar
 
Ad

Recently uploaded (20)

PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
CDH. pptx
AneetaSharma15
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Basics and rules of probability with real-life uses
ravatkaran694
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 

Class diagram and its importance in software

  • 1. © Dr. Khalid Nazim S.A. B.E., M. Tech, MBA[IT], PhD, LMISTE, LMCSI, MIE Associate Professor, Department of Computer Science & Information, Majmaah University, Az- Zulfi Campus, KSA. CS 413: Software Modeling and Analysis
  • 2. Week 13 Topics to be Discussed:  What are class Diagrams?  What is a class?  CRC(Class, Responsibility, Collaborator)  UML Class Diagram Notation  How to draw Class Diagrams  Relationships between classes  Purpose of Class Diagrams  Benefits of Class Diagrams  Simple Examples
  • 4. Design Phase Design : specifying the structure of how a software system will be written and function, without writing the complete implementation. A transition from "what" the system must do, to "how" the system will do it 1. What classes will we need to implement a system that meets our requirements? 2. What fields and methods will each class have? 3. How will the classes interact with each other?
  • 5. Customer Account Opens account Knows name Knows address Account Manager Knows interest rate Knows balance Handles deposits Reports fraud to manager CRC (Class responsibility collaborator)  A Class-Responsibility-Collaboration (CRC) card is a structured tool used in object-oriented software design.  It captures essential information about a class, including its name, responsibilities, and collaborations with other classes.  CRC cards facilitate collaborative discussions among team members and help in refining the design of software systems.
  • 6. UML Class Diagrams What is a UML class diagram? UML class diagram: a picture of The classes in an OO system, Their fields and methods, Connections between the classes that interact or inherit from each other, Algorithmic details; how a particular behavior is implemented.
  • 7. Class Diagrams Class diagrams are used when developing an object-oriented system model to show the classes in a system and the associations between these classes. An object class can be thought of as a general definition of one kind of system object. An association is a link between classes that indicates that there is some relationship between these classes. When you are developing models during the early stages of the software engineering process, objects represent something in the real world, such as a patient, a prescription, doctor, etc.
  • 8. UML Notation for Classes ClassName The top compartment shows the class name. field1 … fieldn The middle compartment contains the declarations of the fields of the class. method1 … methodm The bottom compartment contains the declarations of the methods
  • 9. How to Draw Class Diagrams Drawing class diagrams involves visualizing the structure of a system, including classes, their attributes, methods, and relationships. Step 1: Identify Classes: 1. Start by identifying the classes in the system. 2. A class represents a blueprint for objects and should encapsulate related attributes and methods. Step 2: List Attributes and Methods: 1. For each class, list its attributes (properties, fields) and methods (functions, operations). 2. Include information such as data types and visibility (public, private, protected). Step 3: Identify Relationships: 1. Determine the relationships between classes. 2. Common relationships include associations, aggregations, compositions, inheritance, and dependencies. 3. Understand the nature and multiplicity of these relationships. Step 4: Create Class Boxes: 1. Draw a rectangle (class box) for each class identified. 2. Place the class name in the top compartment of the box. 3. Divide the box into compartments for attributes and methods.
  • 10. Step 5: Add Attributes and Methods: 1. Inside each class box, list the attributes and methods in their respective compartments. 2. Use visibility notations (+ for public, – for private, # for protected, ~ for package/default). Step 6: Draw Relationships: 1. Draw lines to represent relationships between classes. 2. Use arrows to indicate the direction of associations or dependencies. 3. Different line types or notations may be used for various relationships. Step 7: Label Relationships: 1. Label the relationships with multiplicity and role names if needed. 2. Multiplicity indicates the number of instances involved in the relationship, and role names clarify the role of each class in the relationship. Step 8: Review and Refine: 1. Review the class diagram to ensure it accurately represents the system’s structure and relationships. 2. Refine the diagram as needed based on feedback and requirements. How to Draw Class Diagrams
  • 11. Class attributes attributes (fields, instance variables) visibility name : type [count] = default_value 1. visibility: + public # protected - private ~ package (default) / derived 2. underline static attributes 3. Derived attribute: not stored, but can be computed from other attribute values 4. attribute example: - balance : double = 0.00
  • 12. Class Operations / Methods operations / methods visibility name (parameters) : return_type 1. visibility: + public # protected - private ~ package (default) 2. underline static methods 3. parameter types listed as (name: type) 4. omit return_type on constructors and when return type is void 5. method example: + distance(p1: Point, p2: Point): double
  • 13. Comments represented as a folded note, attached to the appropriate class / method / etc. by a dashed line
  • 15. Relationships between classes Generalization : An inheritance relationship, 1. Inheritance between classes 2. Interface implementation Association : A usage relationship 1. Dependency 2. Aggregation 3. Composition
  • 16. Generalization Relationships Generalization (inheritance) relationships 1. hierarchies drawn top-down with arrows pointing upward to parent 2. line/arrow styles differ, based on whether parent is a(n): 1. class: solid line, black arrow 2. abstract class: solid line, white arrow 3. interface: dashed line, white arrow
  • 17. Associational Relationships Associational (usage) relationships 1. Multiplicity : (how many are used) * ⇒ 0, 1, or more 1 ⇒ 1 exactly 2..4 ⇒ between 2 and 4, inclusive 3..* ⇒ 3 or more 2. Name : (what relationship the objects have) 3. Navigability : (direction)
  • 18.  one-to-one each student must carry exactly one ID card  one-to-many one rectangle list can contain many rectangles Multiplicity of Associations
  • 19. Association Types 1. aggregation: "is part of"  symbolized by a clear white diamond. 2. composition: "is entirely made of"  stronger version of aggregation the parts live and die with the whole.  symbolized by a black diamond. 3. dependency: "uses temporarily"  symbolized by dotted line  often is an implementation detail, not an intrinsic part of that object's state 1 1 Car aggregation Engine Lottery Ticket Random dependency Page Book composition * 1
  • 20. Purpose of Class Diagrams The main purpose of using class diagrams is: 1. This is the only UML that can appropriately depict various aspects of the OOPs concept. 2. Proper design and analysis of applications can be faster and efficient. 3. It is the base for deployment and component diagram. 4. It incorporates forward and reverse engineering.
  • 21. Benefits of Class Diagrams 1. Clarity and Communication 2. Standardization 3. Facilitates Object-Oriented Design 4. Documentation and Maintenance 5. Support for Code Generation
  • 22. Class Diagram : Simple Example
  • 23. Class Diagram Example: 01 Aggregation – Order class contains OrderDetail classes. No arrows; info can flow in both directions
  • 25. DVD Movie VHS Movie Video Game Rental Item Rental Invoice 1..* 1 Customer Checkout Screen 0..1 1 Simple Association Class Abstract Class Simple Aggregation Generalization Composition Multiplicity Class Diagram Example: 03: Video Store
  • 27.  Structural UML diagram provide a visual language for representing the static structure of a system, offering clarity and facilitating communication through class diagrams, object diagrams, package diagrams, and more.  These diagrams offer insights into the relationships, dependencies, and organization of elements within a software system.  UML Class Diagrams are a powerful tool in software engineering, offering significant advantages in clarity, standardization, and support for object-oriented design.  However, it is essential to be aware of their limitations and use them in conjunction with other modeling techniques to achieve a comprehensive understanding of the system. Summary