Introduction to Object‐Oriented Design
Dumitru Radoiu Dumitru Radoiu
Spring 2009
PETRU MAIOR UNIVERSITY
Introduction to Object Oriented Design Dumitru Radoiu Dumitru - - PowerPoint PPT Presentation
Introduction to Object Oriented Design Dumitru Radoiu Dumitru Radoiu Spring 2009 PETRU MAIOR UNIVERSITY Agenda The Characteristics of Object Oriented Design (OOD) The Characteristics of Object Oriented Design (OOD) The Use
PETRU MAIOR UNIVERSITY
Software development activities time Customer
Analysis Design Implementation
= attempt to understand = model the behavior = implement the model Requirements Deliverables Needs
Exclusions Baseline Implementation
Requirements Needs
Specifications Baseline Implementation
Procedural approach = multiple procedures modify global data time
Analysis Design Implementation
= attempt to understand = model the behavior = implement the model Requirements Deliverables Needs
Edit Data Load Data P i t D t
Requirements Needs
View Data Save Data Print Data
Everything is exposed; Everything is exposed; updating business rules does not update the entire application.
Object-Oriented approach: objects talk to other objects to complete a task time
Analysis Design Implementation
= attempt to understand = model the behavior = implement the model Requirements Deliverables Needs Data Requirements Needs Functionality Functionalities are Functionalities are encapsulated; only some are exposed (Interfaces)
Object-Oriented Analysis (OOA) time
OO Analysis Design Implementation
= what abstract entities/objects are required to future system? = model the behavior = implement the model Requirements Deliverables Needs Data Requirements Needs Functionality Functionalities are Functionalities are encapsulated; only some are exposed (Interfaces)
Object
Object-Oriented Design (OOD) time
OO Analysis OO Design Implementation
= implement the model = model the behavior for the system to exist = what abstract entities/objects are required to future system? Requirements Deliverables Needs Data Requirements Needs Functionality
Object
Object-Oriented Programming (OOP) time
OO Analysis OO Design OO Programming
= implement the model in an Object Oriented Language (OOL) = model the behavior for the system to exist = what abstract entities/objects are required to future system? Requirements Deliverables Needs Data Requirements Needs Functionality
Object-Oriented World time
OO Analysis OO Design OO Programming
Create the vocabulary Give vocabulary Program the model Requirements Deliverables vocabulary
behavior (model the system)
Object-Oriented Design time
OO Analysis OO Design OO Programming
Create the vocabulary Give vocabulary Program the model Requirements Deliverables vocabulary
behavior (model the system)
Principles: 1. Classes (abstraction and encapsulation) 2. Inheritance 3. Polymorphism
What makes a class: abstraction (= create a general term for an item)
transportation plane ship automobile truck car SUV
“A ____ is a type of ____.”
What makes a class: encapsulation ( = stuff the item with data and functionality)
name data functionality functionality name
black box
name data input
functionality input
Interface = restricted access to functionality = lower maintenance & problem prevention
Object-Oriented Programming (OOP) time
OO Analysis OO Design OO Programming
= implement the model in an Object Oriented Language (OOL) = model the behavior for the system to exist = what abstract entities/objects are required to future system? Requirements Deliverables Needs Data Requirements Needs Functionality
Object-Oriented Programming (OOP) time
OO Analysis OO Design OO Programming
= implement the model in an Object Oriented Language (OOL) = model the behavior for the system to exist = what abstract entities/objects are required to future system? Di l Requirements Deliverables Needs Data Display
+Print() Requirements Needs
+Save() +Load() +View() Menu Load()
+Create() +Edit()
transportation
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 C Subclass C1 Subclass C2 Subclass C3
The use of Inheritance in OOD
automobile
Nr.OfWheels +Drive() +Reverse() +Park() Park() truck car SUV
+ Tow() +Load() +Unload() + Trolley()
Multiple Inheritance
Vehicle
Weapon
+Drive() +Reverse() +Park() +Start() +Load() +Fire() +Aim() +Start() +Stop() Tank
+ Ram() +Radio()
The use of Polymorphism in OOD
Animal
+ Eat() +Sleep() Lion Bird + Run() +Sleep() + Fly() +Sleep() Polymorphism = classes with the same interface operate on their data differently
Creating a Class Diagram: Case study Information to build the class diagram:
g g
eac e a d a p o esso a e
s uc o s
can be assisted by one assistant, while a professor can be assisted by up to five assistants
Student U d d t G d t Undergraduate Graduate
An undergraduate student can be a type of tutor An undergraduate student can be a type of tutor
Student T t U d d t G d t Tutor Undergraduate Graduate
A tutor tutors a student A tutor tutors a student
Student T t tutors> U d d t G d t Tutor Undergraduate Graduate
A teacher and a professor are two types of instructors A teacher and a professor are two types of instructors
Student T t tutors> Instructor U d d t G d t Tutor Undergraduate Graduate Teacher Professor
A teacher assistant can assist a professor and a teacher; a teacher can b i d b i hil f b i d b be assisted by one assistant, while a professor can be assisted by up to five assistants
Student T t tutors> Instructor U d d t G d t Tutor Undergraduate Graduate Teacher Professor 1 1 TeacherAssistant 0..1 0..4
A teacher assistant is a type of graduate student
Student tutors> Instructor Tutor tutors> Undergraduate Graduate Teacher Professor 1 1 TeacherAssistant 0..1 0..4
Read the following scenario and perform the required activities:
The assigned project requires to build an on‐line store with the following characteristics: ‐ Customers can buy different physical objects which will be delivered f ll i t following payment ‐ Payment can be made via credit card (arrangements with a third party are already made)
Activities:
2 D th U C Di f ft t hi h t th b i