SlideShare a Scribd company logo
1 of 16
Download to read offline
1
Pattern-Oriented Software Design
Introduction to
UML Class Diagrams
CSIE Department, NTUT
Woei-Kae Chen
UML: Unified Modeling Language
Successor to OOA&D methods
late 1980s and early 1990s
Unifies
Jacobson & OMT (Booch & Rumbaugh)
Graphical notation used to express
designs
Use cases
Class diagrams
Interaction diagrams
Sequence diagrams
Collaboration diagrams
Package diagrams
State diagrams
Activity diagrams
Deployment diagrams
GoF Book
2
UML class diagrams
Three perspectives
Conceptual
represents of the domain under study
relate to the class that implement them, but often
no direct mapping
Specification
looking at types rather than classes
a type represents an interface that may have
different implementations
Implementation
looking at classes for our POSD class
UML: a class
+ public
# protected
- private
Abstract
Concrete
•data type
•parameter
3
Example: OBSort1.cpp
Example: OBSort1.cpp
Let’s think of
main() as a class
relationship
4
UML: class relationship
Association (knows a)
Dependency (uses a)
Composition (has a)
Aggregation (has a)
Inheritance (is a)
Class template
X
Y
X Y
X Y
X Y
X Y
Y
X
(parameterized
class)
“Uses a” “Knows a” relationship
“Uses a”
Dependency
One object issues a function
call to a member function of
another object
“Knows a”
Association
One object is aware of
another; it contains a pointer
or reference to another object
X Y
X Y
5
“Is a” “Has a” relationship
“Is a” relationships
Inheritance
A class is derived from
another class
“Has a” relationships
Composition or Aggregation
A class contains other
classes as members
X
Y
X Y
X Y
Aggregation Composition
Both are “Has a” or “part-of” relationship
Composition
A stronger variety of aggregation
The part object may belong to only one
whole
Expected to live and die with the whole
delete whole delete part
Aggregation
Cascading delete is often
An aggregated instance can be shared
X Y X Y
Following Larman OOAD:
use of aggregation is NOT
recommended
6
Example: “has a” relationship
Multiplicity
a Point may appear in only
one Polygon or Circle
a Style may be shared by
many Polygons and Circles
Delete Polygon delete Point
Delete Polygon delete StyleX
Larman: use
association instead
of aggregation
Relationship Examples
Car Engine ?
Person Cell Phone ?
Human Brain ?
Fighter Bomb ?
Fighter F16
Bomb Explosive
Bomb Nuclear Bomb
MyComplex Math ?
Tree Node Child Node ?
Tree Node Parent Node ?
Hero Life ?
Hero Score ?
Hero Map ?
Composition
Association/Composition/Dependency
Composition
Association
Inheritance
Composition/Association/Inheritance
Inheritance
Dependency
Composition
Association (if needed)
Composition/Attribute
Association/Dependency
Association/Dependency
7
Relationship Examples
Flight 123 Airplane ?
Flight 123 Airport ?
Flight 123 Passenger ?
Flight 123 Flight Captain ?
Flight 123 Flight Attendant ?
Airplane Boeing 747 ?
Airplane Seat ?
Airplane Fuel ?
Passenger Flight ?
Passenger Ticket ?
Passenger Travel Agent ?
Ticket Price ?
Association/Dependency
Association
Association/Dependency
Association/Dependency
Association/Dependency
Inheritance
Composition
Composition/Attribute
Association/Dependency
Association/Dependency
Association/Dependency
Composition/Attribute
UML Example (C++): Association
X Y
class X {
X(Y *y) : y_ptr(y) {}
void SetY(Y *y) {y_ptr = y;}
void f() {y_ptr->Foo();}
...
Y *y_ptr; // pointer
};
8
UML Example (C++): Association
X Y
How is an association created?
Example #1 Example #2
… …
Y an_y(); Y an_y();
X an_x(&an_y); X an_x();
an_x.f(); …
… an_x.SetY(&y);
… …
an_x.f();
UML Example (C++): Dependency
X Y
class X {
...
void f1(Y y) {…; y.Foo();}
void f2(Y *y) {…; y->Foo();}
void f3(Y &y) {…; y.Foo();}
void f4() {Y y; y.Foo();…}
void f5() {…; Y::StaticFoo();}
};
9
Example: OBSort3.cpp
uses
•getSize()
•operator[]
UML Example (C++): Composition 1
class X {
...
Y a; // 1; Composition
Y b[10]; // 0..10; Composition
};
X Y
Java?
10
UML Example (C++): Composition 2
class X {
X() { a = new Y[10]; }
~X(){ delete [] a; }
...
Y *a; // 0..10; Composition
};
NOT Association
X Y
UML Example (C++): Composition 3
class X {
...
vector<Y> a;
};
X vector<Y> Y
X Y
Hiding
implementation detail
Implementation detail
Composition of
vector<Y>
NOT Composition
of Y
11
UML Example: OBSort3.cpp
UML Example (C++): Aggregation
X Y
No example here
Use Association instead of Aggregation
X Y
12
UML Example (C++): Inheritance
class Y {
...
};
class X : public Y {
...
};
X
Y
“is a” relationship
Example: OOSort2.cpp
13
UML Example (C#): Implementation
public interface Y {
int Foo();
}
class X : Y
{
public int Foo()
{
…
}
}
X
Y
X implements Y
No fields
“Can do” relationship
UML Example (C++): Implementation
class Y {
...
};
class X : public Y {
...
};
X
YNo variables
Only pure virtual functions
C++ allows multiple inheritance
14
UML Example (C++):
Template Class
template <class T>
class X {
...
...
...
};
X
Y
...
X<Y> a;
...
15
Abstract class
16
C++ static member

More Related Content

What's hot

What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaEdureka!
 
Chapter 9 Abstract Class
Chapter 9 Abstract ClassChapter 9 Abstract Class
Chapter 9 Abstract ClassOUM SAOKOSAL
 
OOP Concepets and UML Class Diagrams
OOP Concepets and UML Class DiagramsOOP Concepets and UML Class Diagrams
OOP Concepets and UML Class DiagramsBhathiya Nuwan
 
C#, OOP introduction and examples
C#, OOP introduction and examplesC#, OOP introduction and examples
C#, OOP introduction and examplesagni_agbc
 
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...cprogrammings
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceOUM SAOKOSAL
 
Java Programming - Abstract Class and Interface
Java Programming - Abstract Class and InterfaceJava Programming - Abstract Class and Interface
Java Programming - Abstract Class and InterfaceOum Saokosal
 
Advanced c#
Advanced c#Advanced c#
Advanced c#saranuru
 
Java interfaces
Java interfacesJava interfaces
Java interfacesjehan1987
 

What's hot (14)

What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | Edureka
 
Abstract method
Abstract methodAbstract method
Abstract method
 
Generics
GenericsGenerics
Generics
 
Chapter 9 Abstract Class
Chapter 9 Abstract ClassChapter 9 Abstract Class
Chapter 9 Abstract Class
 
Abstract classes
Abstract classesAbstract classes
Abstract classes
 
OOP Concepets and UML Class Diagrams
OOP Concepets and UML Class DiagramsOOP Concepets and UML Class Diagrams
OOP Concepets and UML Class Diagrams
 
C#, OOP introduction and examples
C#, OOP introduction and examplesC#, OOP introduction and examples
C#, OOP introduction and examples
 
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
 
Java Programming - Abstract Class and Interface
Java Programming - Abstract Class and InterfaceJava Programming - Abstract Class and Interface
Java Programming - Abstract Class and Interface
 
Interfaces
InterfacesInterfaces
Interfaces
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 

Viewers also liked

Program keajaiban sedekah
Program keajaiban sedekahProgram keajaiban sedekah
Program keajaiban sedekahrheyfan17
 
Membuat mail server di ubuntu
Membuat mail server di ubuntuMembuat mail server di ubuntu
Membuat mail server di ubuntuIwan Kurniarasa
 
Career education-review-robert-starks-jr-social-media-strategies-max knowledge
Career education-review-robert-starks-jr-social-media-strategies-max knowledgeCareer education-review-robert-starks-jr-social-media-strategies-max knowledge
Career education-review-robert-starks-jr-social-media-strategies-max knowledgeMaxKnowledge
 
Understanding the Social Shift: How State Associations of Private Postseconda...
Understanding the Social Shift: How State Associations of Private Postseconda...Understanding the Social Shift: How State Associations of Private Postseconda...
Understanding the Social Shift: How State Associations of Private Postseconda...MaxKnowledge
 
Membangun web server,_e-mail_server_dan_ftp_server
Membangun web server,_e-mail_server_dan_ftp_serverMembangun web server,_e-mail_server_dan_ftp_server
Membangun web server,_e-mail_server_dan_ftp_serverIwan Kurniarasa
 
Social media im patentwesen
Social media im patentwesenSocial media im patentwesen
Social media im patentwesenTim Jagodzinski
 
Curso e proinfo
Curso e proinfoCurso e proinfo
Curso e proinfoFatimaLucy
 
Curriculum Vitae of Jean Christophe ROBLES (latest update)
Curriculum Vitae of Jean Christophe ROBLES (latest update)Curriculum Vitae of Jean Christophe ROBLES (latest update)
Curriculum Vitae of Jean Christophe ROBLES (latest update)Jean Christophe Robles Espinosa
 
Engage at Melcrum Summit 2012
Engage at Melcrum Summit 2012Engage at Melcrum Summit 2012
Engage at Melcrum Summit 2012Engage Group
 

Viewers also liked (20)

Resume of Jean Christophe ROBLES
Resume of Jean Christophe ROBLESResume of Jean Christophe ROBLES
Resume of Jean Christophe ROBLES
 
Program keajaiban sedekah
Program keajaiban sedekahProgram keajaiban sedekah
Program keajaiban sedekah
 
Function
FunctionFunction
Function
 
2
22
2
 
Membuat mail server di ubuntu
Membuat mail server di ubuntuMembuat mail server di ubuntu
Membuat mail server di ubuntu
 
Curriculum Vitae of Jean Christophe ROBLES
Curriculum Vitae of Jean Christophe ROBLESCurriculum Vitae of Jean Christophe ROBLES
Curriculum Vitae of Jean Christophe ROBLES
 
5
55
5
 
Psikologi perkembangan
Psikologi perkembanganPsikologi perkembangan
Psikologi perkembangan
 
Dell case study 1
Dell case study 1Dell case study 1
Dell case study 1
 
Data encryption standar
Data encryption standarData encryption standar
Data encryption standar
 
Career education-review-robert-starks-jr-social-media-strategies-max knowledge
Career education-review-robert-starks-jr-social-media-strategies-max knowledgeCareer education-review-robert-starks-jr-social-media-strategies-max knowledge
Career education-review-robert-starks-jr-social-media-strategies-max knowledge
 
Understanding the Social Shift: How State Associations of Private Postseconda...
Understanding the Social Shift: How State Associations of Private Postseconda...Understanding the Social Shift: How State Associations of Private Postseconda...
Understanding the Social Shift: How State Associations of Private Postseconda...
 
Evaluación educativa 04 11-2016
Evaluación educativa 04 11-2016Evaluación educativa 04 11-2016
Evaluación educativa 04 11-2016
 
Membangun web server,_e-mail_server_dan_ftp_server
Membangun web server,_e-mail_server_dan_ftp_serverMembangun web server,_e-mail_server_dan_ftp_server
Membangun web server,_e-mail_server_dan_ftp_server
 
5
55
5
 
Windows phone and azure
Windows phone and azureWindows phone and azure
Windows phone and azure
 
Social media im patentwesen
Social media im patentwesenSocial media im patentwesen
Social media im patentwesen
 
Curso e proinfo
Curso e proinfoCurso e proinfo
Curso e proinfo
 
Curriculum Vitae of Jean Christophe ROBLES (latest update)
Curriculum Vitae of Jean Christophe ROBLES (latest update)Curriculum Vitae of Jean Christophe ROBLES (latest update)
Curriculum Vitae of Jean Christophe ROBLES (latest update)
 
Engage at Melcrum Summit 2012
Engage at Melcrum Summit 2012Engage at Melcrum Summit 2012
Engage at Melcrum Summit 2012
 

Similar to Intro uml

Introduction to UML, a guide to learn.pdf
Introduction to UML, a guide to learn.pdfIntroduction to UML, a guide to learn.pdf
Introduction to UML, a guide to learn.pdfTARGARYEN001
 
SDA ClassDiagram.ppt
SDA ClassDiagram.pptSDA ClassDiagram.ppt
SDA ClassDiagram.pptAteeqaKokab1
 
UML_Lecture.pptxnd bfdjjrnekdddkeeeenekejneje
UML_Lecture.pptxnd bfdjjrnekdddkeeeenekejnejeUML_Lecture.pptxnd bfdjjrnekdddkeeeenekejneje
UML_Lecture.pptxnd bfdjjrnekdddkeeeenekejnejessusera6a60c1
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering Madhar Khan Pathan
 
Object Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLObject Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLMalek Sumaiya
 
08 class and sequence diagrams
08   class and sequence diagrams08   class and sequence diagrams
08 class and sequence diagramskebsterz
 
UML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework HelpUML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework HelpJacob William
 
UML- Unified Modeling Language
UML- Unified Modeling LanguageUML- Unified Modeling Language
UML- Unified Modeling LanguageShahzad
 
Uml struct2
Uml struct2Uml struct2
Uml struct2Student
 
Unified modeling language
Unified modeling languageUnified modeling language
Unified modeling languageamity2j
 

Similar to Intro uml (20)

Unified Modeling Language
Unified Modeling LanguageUnified Modeling Language
Unified Modeling Language
 
Introduction to UML, a guide to learn.pdf
Introduction to UML, a guide to learn.pdfIntroduction to UML, a guide to learn.pdf
Introduction to UML, a guide to learn.pdf
 
SDA ClassDiagram.ppt
SDA ClassDiagram.pptSDA ClassDiagram.ppt
SDA ClassDiagram.ppt
 
Intro Uml
Intro UmlIntro Uml
Intro Uml
 
UML_Lecture.pptxnd bfdjjrnekdddkeeeenekejneje
UML_Lecture.pptxnd bfdjjrnekdddkeeeenekejnejeUML_Lecture.pptxnd bfdjjrnekdddkeeeenekejneje
UML_Lecture.pptxnd bfdjjrnekdddkeeeenekejneje
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
UML Basics
UML BasicsUML Basics
UML Basics
 
Uml lecture
Uml lectureUml lecture
Uml lecture
 
Object Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLObject Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UML
 
08 class and sequence diagrams
08   class and sequence diagrams08   class and sequence diagrams
08 class and sequence diagrams
 
UML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework HelpUML Diagram Assignment Help, UML Diagram Homework Help
UML Diagram Assignment Help, UML Diagram Homework Help
 
09 inheritance and_uml
09 inheritance and_uml09 inheritance and_uml
09 inheritance and_uml
 
2 class use case
2 class use case2 class use case
2 class use case
 
UML- Unified Modeling Language
UML- Unified Modeling LanguageUML- Unified Modeling Language
UML- Unified Modeling Language
 
4. UML
4. UML4. UML
4. UML
 
Uml report
Uml reportUml report
Uml report
 
Css uml
Css umlCss uml
Css uml
 
Uml
UmlUml
Uml
 
Uml struct2
Uml struct2Uml struct2
Uml struct2
 
Unified modeling language
Unified modeling languageUnified modeling language
Unified modeling language
 

Recently uploaded

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Recently uploaded (20)

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

Intro uml

  • 1. 1 Pattern-Oriented Software Design Introduction to UML Class Diagrams CSIE Department, NTUT Woei-Kae Chen UML: Unified Modeling Language Successor to OOA&D methods late 1980s and early 1990s Unifies Jacobson & OMT (Booch & Rumbaugh) Graphical notation used to express designs Use cases Class diagrams Interaction diagrams Sequence diagrams Collaboration diagrams Package diagrams State diagrams Activity diagrams Deployment diagrams GoF Book
  • 2. 2 UML class diagrams Three perspectives Conceptual represents of the domain under study relate to the class that implement them, but often no direct mapping Specification looking at types rather than classes a type represents an interface that may have different implementations Implementation looking at classes for our POSD class UML: a class + public # protected - private Abstract Concrete •data type •parameter
  • 3. 3 Example: OBSort1.cpp Example: OBSort1.cpp Let’s think of main() as a class relationship
  • 4. 4 UML: class relationship Association (knows a) Dependency (uses a) Composition (has a) Aggregation (has a) Inheritance (is a) Class template X Y X Y X Y X Y X Y Y X (parameterized class) “Uses a” “Knows a” relationship “Uses a” Dependency One object issues a function call to a member function of another object “Knows a” Association One object is aware of another; it contains a pointer or reference to another object X Y X Y
  • 5. 5 “Is a” “Has a” relationship “Is a” relationships Inheritance A class is derived from another class “Has a” relationships Composition or Aggregation A class contains other classes as members X Y X Y X Y Aggregation Composition Both are “Has a” or “part-of” relationship Composition A stronger variety of aggregation The part object may belong to only one whole Expected to live and die with the whole delete whole delete part Aggregation Cascading delete is often An aggregated instance can be shared X Y X Y Following Larman OOAD: use of aggregation is NOT recommended
  • 6. 6 Example: “has a” relationship Multiplicity a Point may appear in only one Polygon or Circle a Style may be shared by many Polygons and Circles Delete Polygon delete Point Delete Polygon delete StyleX Larman: use association instead of aggregation Relationship Examples Car Engine ? Person Cell Phone ? Human Brain ? Fighter Bomb ? Fighter F16 Bomb Explosive Bomb Nuclear Bomb MyComplex Math ? Tree Node Child Node ? Tree Node Parent Node ? Hero Life ? Hero Score ? Hero Map ? Composition Association/Composition/Dependency Composition Association Inheritance Composition/Association/Inheritance Inheritance Dependency Composition Association (if needed) Composition/Attribute Association/Dependency Association/Dependency
  • 7. 7 Relationship Examples Flight 123 Airplane ? Flight 123 Airport ? Flight 123 Passenger ? Flight 123 Flight Captain ? Flight 123 Flight Attendant ? Airplane Boeing 747 ? Airplane Seat ? Airplane Fuel ? Passenger Flight ? Passenger Ticket ? Passenger Travel Agent ? Ticket Price ? Association/Dependency Association Association/Dependency Association/Dependency Association/Dependency Inheritance Composition Composition/Attribute Association/Dependency Association/Dependency Association/Dependency Composition/Attribute UML Example (C++): Association X Y class X { X(Y *y) : y_ptr(y) {} void SetY(Y *y) {y_ptr = y;} void f() {y_ptr->Foo();} ... Y *y_ptr; // pointer };
  • 8. 8 UML Example (C++): Association X Y How is an association created? Example #1 Example #2 … … Y an_y(); Y an_y(); X an_x(&an_y); X an_x(); an_x.f(); … … an_x.SetY(&y); … … an_x.f(); UML Example (C++): Dependency X Y class X { ... void f1(Y y) {…; y.Foo();} void f2(Y *y) {…; y->Foo();} void f3(Y &y) {…; y.Foo();} void f4() {Y y; y.Foo();…} void f5() {…; Y::StaticFoo();} };
  • 9. 9 Example: OBSort3.cpp uses •getSize() •operator[] UML Example (C++): Composition 1 class X { ... Y a; // 1; Composition Y b[10]; // 0..10; Composition }; X Y Java?
  • 10. 10 UML Example (C++): Composition 2 class X { X() { a = new Y[10]; } ~X(){ delete [] a; } ... Y *a; // 0..10; Composition }; NOT Association X Y UML Example (C++): Composition 3 class X { ... vector<Y> a; }; X vector<Y> Y X Y Hiding implementation detail Implementation detail Composition of vector<Y> NOT Composition of Y
  • 11. 11 UML Example: OBSort3.cpp UML Example (C++): Aggregation X Y No example here Use Association instead of Aggregation X Y
  • 12. 12 UML Example (C++): Inheritance class Y { ... }; class X : public Y { ... }; X Y “is a” relationship Example: OOSort2.cpp
  • 13. 13 UML Example (C#): Implementation public interface Y { int Foo(); } class X : Y { public int Foo() { … } } X Y X implements Y No fields “Can do” relationship UML Example (C++): Implementation class Y { ... }; class X : public Y { ... }; X YNo variables Only pure virtual functions C++ allows multiple inheritance
  • 14. 14 UML Example (C++): Template Class template <class T> class X { ... ... ... }; X Y ... X<Y> a; ...