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

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
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.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
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
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
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
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 

Recently uploaded (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
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 ...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
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
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
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...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 

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; ...