ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่ 8...

Post on 25-Feb-2016

37 views 2 download

description

ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่ 8 Object-Oriented Software Design. ปริญญา น้อยดอนไพร สาขาวิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยราช ภัฏ สุราษฎร์ธานี. Object-Oriented Software Design. Object-Oriented Concept Introduction to Object-Oriented Software Design. - PowerPoint PPT Presentation

Transcript of ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่ 8...

ซอฟตแวรพฒนาระบบฐานขอมล

บทท 10 Object-Oriented Software Designผชวยศาสตราจารยปรญญา นอยดอนไพร

สาขาวชาวทยาการคอมพวเตอร คณะวทยาศาสตรและเทคโนโลย

มหาวทยาลยราชภฏสราษฎรธาน

Object-Oriented Software Design

• Object-Oriented Concept• Introduction to Object-Oriented

Software Design

Object-Oriented Concept

• Object & Class• Inheritance (การสบทอด)• Polymorphism• Encapsulation• Class Relationship

Introduction to Object-Oriented Software Design

Object-Oriented Concept

• Object & Class• Inheritance• Polymorphism• Encapsulation• Class Relationship

Object• Object World• Message• Method/Operation• Interface• Event• Responsibilities

Object

Object

Click ( )

Object

Person Post OfficeDeliver (Mail)

DeliverSend Mail

Object

Person Vending Machine

Buy Pepsi

Sell (10 Baht, Pepsi)

Sell

Object

Person Elevator

Go to 3rd floor

MoveToFloor (3)

MoveToFloorOpenClose

ClassPerson

Somchai

Somsri

Somsak

Somying

ClassStudent

Somchai

Somsri

Somsak

Somying

ClassTennis Player

Paradorn

Venus

Marat

Martina

ClassInstitute

Social Technology

Engineering

Science

Agricultural Technology

Class• Template• Name• Attributes• Operations• Responsibilities

Class

Name

Attributes

Operations

Responsibilities

ClassStudent

StudentIDFirstNameLastNameAddressetc…RegisterForCourseDropCourseetc...

ClassTennis Player

FirstNameLastNameNationalityRankingetc…RegisterForTournamentetc...

ClassCar

Car Reg. NumberMakerModelColoretc…AccelerateStopetc...

ClassAirplane

Plane NumberManufacturerModeletc…TakeOffLandingetc...

Object & ClassStudent

Somchai

Somsri

Somsak

Somying

Object & ClassStudent

Somchai

Somsri

Somsak

Somying

StudentStudentIDFirstNameLastNameAddressetc…

RegisterForCourseDropCourseetc...

Object & ClassStudent

Somchai

Somsri

Somsak

Somying

Student1B4555555SomchaiSaetung7146 Suranivet 7etc…

RegisterForCourseDropCourseetc...

Student1B4555555SomchaiSaetung7146 Suranivet 7etc…RegisterForCourseDropCourseetc...

StudentStudentIDFirstNameLastNameAddressetc…RegisterForCourseDropCourseetc...

Object-Oriented Concept

• Object & Class• Inheritance• Polymorphism• Encapsulation• Class Relationship

Inheritance

Animal

Dog PersonCat

Inheritance

Land Vehicle

Truck CarBus

Inheritance

Transaction

Rental Transaction

Lease Transaction

Sales Transaction

Inheritance• Class Hierarchy• Sub Class• Super Class• Reusability• Overriding

InheritanceLand Vehicle

Car

Toyota

TruckBus

Vios Altis Camry

TransactiontransNotransDatetransTimeetc…

Rental Transaction

Lease Transaction

Sales TransactiontransNotransDatetransTimeetc…quantitySold…

transNotransDatetransTimeetc…memberNo…

transNotransDatetransTimeetc…duration…

Object-Oriented Concept

• Object & Class• Inheritance• Polymorphism• Encapsulation• Class Relationship

Polymorphism

DrawChart

DrawChart(1)

DrawChart(1,2,1,2)

DrawChart(1,1,1)DrawTriangle(1,1,1)

DrawRect(1,2,1,2)

DrawCircle(1)

Polymorphism• Add(integer, integer)• Add(string, string)• Add(string, integer)

Add(1,1) 2 Add(“Hello”, “World”) “HelloWorld” Add(“Hello”, 2) “Hello2” Add(2, “Hello”) ?

Polymorphism

:PaySlip

:HourlyPaidEmployee

:WeeklyPaidEmployee

:MonthlyPaidEmployee

getTotalPay()

calculatePay()

calculatePay()

calculatePay()

Polymorphism• Overloading

Object-Oriented Concept

• Object & Class• Inheritance• Polymorphism• Encapsulation• Class Relationship

Encapsulation• Abstraction• Information Hiding• Security

EncapsulationStudent

StudentID: B4555555FirstName: SomchaiLastName: SaetungCourses Registered: [204204], [204203] etc…DropCourseSetNameGetNameetc...

Encapsulation

Person Vending Machine

Buy Pepsi

Sell (10 Baht, Pepsi)

Sell

Object-Oriented Concept

• Object & Class• Inheritance• Polymorphism• Encapsulation• Class Relationship

Class Relationship• Association• Aggregation• Composition• Generalization

Class Relationship• Association

Pilot Planes

Class Relationship

• Association– Son – Father– Customer – Operator– User - Computer

Class Relationship• Composition

Car

Seat WheelEngine

Class Relationship• Composition

– Car – Wheel, Engine, Seat– House – Window, Roof, Door, Wall– Computer – Monitor, CPU, Keyboard– Building – Rooms – Circle – Points– Book - Chapter

Class Relationship• Aggregation

Classroom Student

Class Relationship

• Aggregation– Classroom – Student– Keyboard – Key– Notebook – Paper– Computer – Monitor, CPU, Keyboard

Class Relationship• Generalization

Land Vehicle

Truck CarBus

Class Relationship• Generalization

– Car – Mercedes-Benz, BMW, Lexus– Animal – Cat, Rat, Dog

Introduction to Object-Oriented Software Design