Vous êtes sur la page 1sur 32

Introductionto ObjectOrientedDesign

DumitruRadoiu Dumitru Radoiu


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

Design

Implementation

= attempt to understand

= model the behavior

= implement the model

Exclusions

Deliverables Needs Requirements


Baseline Implementation

Specifications

Procedural approach = multiple procedures modify global data

time

Analysis

Design

Implementation

= attempt to understand

= model the behavior

= implement the model

Edit Data

Load Data

Deliverables Needs Requirements


Print Data Pi tD 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

Analysis

Design

Implementation

= attempt to understand

= model the behavior

= implement the model

Deliverables Needs Requirements Data Functionality Functionalitiesare Functionalities are encapsulated;onlysomeare 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

Deliverables Needs Requirements Data Functionality Functionalitiesare Functionalities are encapsulated;onlysomeare exposed(Interfaces)

Object

Object-Oriented Design (OOD)

time

OO Analysis

OO Design

Implementation

= what abstract entities/objects are required to future system?

= model the behavior for the system to exist

= implement the model

Deliverables Needs Requirements Data Functionality

Object

Object-Oriented Programming (OOP)

time

OO Analysis

OO Design

OO Programming

= what abstract entities/objects are required to future system?

= model the behavior for the system to exist

= implement the model in an Object Oriented Language (OOL)

Deliverables Needs Requirements Data Functionality

Object-Oriented World

time

OO Analysis

OO Design

OO Programming

Create the vocabulary

Requirements

Give vocabulary ocabu a y behavior (model the system)

Program the model ode

Deliverables

Object-Oriented Design

time

OO Analysis

OO Design

OO Programming

Create the vocabulary

Requirements

Give vocabulary ocabu a y behavior (model the system)

Program the model ode

Deliverables

Principles: 1. Classes (abstraction and encapsulation) 2. Inheritance 3. Polymorphism

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

car

SUV

A____isatypeof____.

What makes a class: encapsulation ( = stuff the item with data and functionality)

name data

functionality
black box

name data input functionality output

Interface=restrictedaccesstofunctionality=lower maintenance&problemprevention

Object-Oriented Programming (OOP)

time

OO Analysis

OO Design

OO Programming

= what abstract entities/objects are required to future system?

= model the behavior for the system to exist

= implement the model in an Object Oriented Language (OOL)

Deliverables Needs Requirements Data Functionality

Object-Oriented Programming (OOP)

time

OO Analysis

OO Design

OO Programming

= what abstract entities/objects are required to future system?

= model the behavior for the system to exist Display Di l -Data

= implement the model in an Object Oriented Language (OOL)

Needs

Requirements

Data -Data +Save() +Load() Load()

+Print() +View() 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 C

Subclass C1

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
Vehicle -FuelType - SeatingCapacity +Drive() +Reverse() +Park() +Start() +Stop() Weapon -ArtileryCapacity - ArtileryType +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

Bird

+ Run() +Sleep()

+ 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

Astudentcanbeanundergraduatestudentoragraduatestudent A student can be an undergraduate student or a graduate student


Student

Undergraduate U d d t

Graduate G d t

Anundergraduatestudentcanbeatypeoftutor An undergraduate student can be a type of tutor


Student Tutor T t

Undergraduate U d d t

Graduate G d t

Atutortutorsastudent A tutor tutors a student


tutors> Tutor T t Student

Undergraduate U d d t

Graduate G d t

Ateacherandaprofessoraretwotypesofinstructors A teacher and a professor are two types of instructors


tutors> Tutor T t Student Instructor

Undergraduate U d d t

Graduate G d t

Teacher

Professor

Ateacherassistantcanassistaprofessorandateacher;ateachercan beassistedbyoneassistant,whileaprofessorcanbeassistedbyup b i db i hil f b i db tofiveassistants


tutors> Tutor T t Student Instructor

Undergraduate U d d t

Graduate G d t

Teacher 1 0..1

Professor 1 0..4

TeacherAssistant

Ateacherassistantisatypeofgraduatestudent
tutors> Tutor Student Instructor

Undergraduate

Graduate

Teacher 1 0..1

Professor 1 0..4

TeacherAssistant

Project
Readthefollowingscenarioandperformtherequiredactivities:

Theassignedprojectrequirestobuildanonlinestorewiththe followingcharacteristics: Customerscanbuydifferentphysicalobjectswhichwillbedelivered followingpayment f ll i t Paymentcanbemadeviacreditcard(arrangementswithathird partyarealreadymade)

Activities: 1. 2. 2 3. 4. 5. UsingBPMN(BusinessProcessModelingNotation)modelthebusiness DrawtheUseCaseDiagramofasoftwaresystemwhichsupportsthebusiness D th U C Di f ft t hi h t th b i DrawtheSequenceDiagramforeachUseCases DrawtheActivityDiagramforeachUseCase DrawtheClassDiagramsforthesystem

Vous aimerez peut-être aussi