Introductionto
ObjectOrientedDesign
Dumitru Radoiu
DumitruRadoiu
Spring2009
PETRU MAIOR UNIVERSITY
Agenda
TheCharacteristicsofObjectOrientedDesign(OOD)
The
Characteristics of Object Oriented Design (OOD)
TheUseofClassesinOOD
TheuseofInheritanceinOOD
TheUseofPolymorphisminOOD
CreatingaClassDiagram:CaseStudy
Software development activities
Customer
time
Analysis
= attempt to
understand
Design
= model the
behavior
Implementation
= implement
the model
Exclusions
Deliverables
Needs
Baseline
Requirements
Specifications
Implementation
Procedural approach = multiple procedures modify global data
time
Design
Analysis
= attempt to
understand
= model the
behavior
Edit Data
Implementation
= implement
the model
Load Data
Deliverables
Needs
Requirements
Pi tD
Print
Data
t
Save Data
View Data
Everythingisexposed;
Everything
is exposed;
updatingbusinessrulesdoes
notupdatetheentire
application.
Object-Oriented approach: objects talk to other objects to complete a task
time
Design
Analysis
= attempt to
understand
= model the
behavior
Implementation
= implement
the model
Deliverables
Needs
Requirements
Data
Functionality
Functionalitiesare
Functionalities
are
encapsulated;onlysomeare
exposed(Interfaces)
Object-Oriented Analysis (OOA)
time
Design
OO Analysis
= what abstract
entities/objects are
required to future
system?
= model the
behavior
Implementation
= implement
the model
Deliverables
Needs
Requirements
Data
Functionality
Object
Functionalitiesare
Functionalities
are
encapsulated;onlysomeare
exposed(Interfaces)
Object-Oriented Design (OOD)
time
OO Design
OO Analysis
= what abstract
entities/objects are
required to future
system?
= model the
behavior for
the system to
exist
Implementation
= implement
the model
Deliverables
Needs
Requirements
Data
Functionality
Object
Object-Oriented Programming (OOP)
time
OO Design
OO Analysis
= what abstract
entities/objects are
required to future
system?
= model the
behavior for
the system to
exist
OO Programming
= implement the model in an
Object Oriented Language
(OOL)
Deliverables
Needs
Requirements
Data
Functionality
Object-Oriented World
time
OO Analysis
Create the
vocabulary
Requirements
OO Design
Give
vocabulary
ocabu a y
behavior
(model the
system)
OO Programming
Program the
model
ode
Deliverables
Object-Oriented Design
time
OO Analysis
Create the
vocabulary
Requirements
OO Design
Give
vocabulary
ocabu a y
behavior
(model the
system)
OO Programming
Program the
model
ode
Principles:
1. Classes (abstraction and encapsulation)
2. Inheritance
3. Polymorphism
Deliverables
Agenda
TheCharacteristicsofObjectOrientedDesign(OOD)
The
Characteristics of Object Oriented Design (OOD)
TheUseofClassesinOOD
TheuseofInheritanceinOOD
TheUseofPolymorphisminOOD
CreatingaClassDiagram:CaseStudy
What makes a class: abstraction (= create a general term for an item)
transportation
plane
ship
automobile
truck
A____isatypeof____.
car
SUV
What makes a class: encapsulation ( = stuff the item with data and functionality)
name
data
functionality
black box
name
data
input
output
functionality
Interface=restrictedaccesstofunctionality=lower
maintenance&problemprevention
Object-Oriented Programming (OOP)
time
OO Design
OO Analysis
= what abstract
entities/objects are
required to future
system?
= model the
behavior for
the system to
exist
OO Programming
= implement the model in an
Object Oriented Language
(OOL)
Deliverables
Needs
Requirements
Data
Functionality
Object-Oriented Programming (OOP)
time
OO Design
OO Analysis
= what abstract
entities/objects are
required to future
system?
= model the
behavior for
the system to
exist
Di l
Display
OO Programming
= implement the model in an
Object Oriented Language
(OOL)
-Data
Needs
Requirements
Data
+Print()
+View()
-Data
+Save()
+Load()
Load()
Menu
-Data
+Create()
+Edit()
Deliverables
Agenda
TheCharacteristicsofObjectOrientedDesign(OOD)
The
Characteristics of Object Oriented Design (OOD)
TheUseofClassesinOOD
TheuseofInheritanceinOOD
TheUseofPolymorphisminOOD
CreatingaClassDiagram:CaseStudy
The use of Inheritance in OOD
transportation
plane
ship
automobile
truck
car
SUV
The use of Inheritance in OOD
Superclass
Subclass A
Subclass B
Subclass C1
Subclass C
Subclass C2
Subclass C3
The use of Inheritance in OOD
automobile
- Nr.OfWheels
Nr OfWheels
+Drive()
+Reverse()
+Park()
Park()
truck
-Nr.OfGears
- Nr.OfTanks
+ Tow()
+Load()
+Unload()
car
-TrunkSize
-SafetyWindows
SUV
-4WD
-BullBar
+ Trolley()
Multiple Inheritance
Weapon
Vehicle
-ArtileryCapacity
- ArtileryType
-FuelType
- SeatingCapacity
+Drive()
+Reverse()
+Park()
+Start()
+Stop()
+Load()
+Fire()
+Aim()
Tank
-Model
+ Ram()
+Radio()
Agenda
TheCharacteristicsofObjectOrientedDesign(OOD)
The
Characteristics of Object Oriented Design (OOD)
TheUseofClassesinOOD
TheuseofInheritanceinOOD
TheUseofPolymorphisminOOD
CreatingaClassDiagram:CaseStudy
The use of Polymorphism in OOD
Animal
-Nr.OfEyes
- Nr.OfLegs
+ Eat()
+Sleep()
Lion
+ Run()
+Sleep()
Bird
+ Fly()
+Sleep()
Polymorphism=classeswiththesameinterfaceoperateontheirdatadifferently
Agenda
TheCharacteristicsofObjectOrientedDesign(OOD)
The
Characteristics of Object Oriented Design (OOD)
TheUseofClassesinOOD
TheuseofInheritanceinOOD
TheUseofPolymorphisminOOD
CreatingaClassDiagram:CaseStudy
Creating a Class Diagram: Case study
Informationtobuildtheclassdiagram:
Astudentcanbeanundergraduatestudentoragraduatestudent
g
g
Anundergraduatestudentcanbeatypeoftutor
Atutortutorsastudent
Ateacherandaprofessoraretwotypesofinstructors
eac e a d a p o esso a e o ypes o s uc o s
Ateacherassistantcanassistaprofessorandateacher;ateacher
canbeassistedbyoneassistant,whileaprofessorcanbeassistedby
uptofiveassistants
Ateacherassistantisatypeofgraduatestudent
A student can be an undergraduate student or a graduate student
Astudentcanbeanundergraduatestudentoragraduatestudent
Student
U d
Undergraduate
d t
G d t
Graduate
An undergraduate student can be a type of tutor
Anundergraduatestudentcanbeatypeoftutor
Student
T t
Tutor
U d
Undergraduate
d t
G d t
Graduate
A tutor tutors a student
Atutortutorsastudent
tutors>
Student
T t
Tutor
U d
Undergraduate
d t
G d t
Graduate
A teacher and a professor are two types of instructors
Ateacherandaprofessoraretwotypesofinstructors
tutors>
Student
T t
Tutor
Instructor
U d
Undergraduate
d t
G d t
Graduate
Teacher
Professor
Ateacherassistantcanassistaprofessorandateacher;ateachercan
b
beassistedbyoneassistant,whileaprofessorcanbeassistedbyup
i db
i
hil
f
b
i db
tofiveassistants
tutors>
Student
T t
Tutor
Instructor
U d
Undergraduate
d t
G d t
Graduate
Teacher
Professor
1
0..1
0..4
TeacherAssistant
Ateacherassistantisatypeofgraduatestudent
tutors>
Student
Instructor
Tutor
Undergraduate
Graduate
Teacher
Professor
1
0..1
0..4
TeacherAssistant
Project
Readthefollowingscenarioandperformtherequiredactivities:
Theassignedprojectrequirestobuildanonlinestorewiththe
followingcharacteristics:
Customerscanbuydifferentphysicalobjectswhichwillbedelivered
f ll i
followingpayment
t
Paymentcanbemadeviacreditcard(arrangementswithathird
partyarealreadymade)
Activities:
1.
2
2.
3.
4.
5.
UsingBPMN(BusinessProcessModelingNotation)modelthebusiness
D
DrawtheUseCaseDiagramofasoftwaresystemwhichsupportsthebusiness
th U C
Di
f
ft
t
hi h
t th b i
DrawtheSequenceDiagramforeachUseCases
DrawtheActivityDiagramforeachUseCase
DrawtheClassDiagramsforthesystem