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

52
ซซซซซซซซซซซซซซ ซซซซซซซซซซซซซ ซซซซซ 10 Object- Oriented Software Design ผผผผผผผผผผผผผผผผผผผผผผผผ ผผผผผผผ ผผผ ผผผผผผผผผผผผผผผผผผผผผผผผผผผ ผผผ ผผผผผผผผผผผผผผผผผผผผผผผ ผผผผผผผผผผผผผผผผผผผผผผผผผผผผผ

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

Page 1: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

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

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

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

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

Page 2: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object-Oriented Software Design

• Object-Oriented Concept• Introduction to Object-Oriented

Software Design

Page 3: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object-Oriented Concept

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

Page 4: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Introduction to Object-Oriented Software Design

Page 5: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object-Oriented Concept

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

Page 6: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

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

Page 7: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object

Page 8: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object

Click ( )

Page 9: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object

Person Post OfficeDeliver (Mail)

DeliverSend Mail

Page 10: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object

Person Vending Machine

Buy Pepsi

Sell (10 Baht, Pepsi)

Sell

Page 11: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object

Person Elevator

Go to 3rd floor

MoveToFloor (3)

MoveToFloorOpenClose

Page 12: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassPerson

Somchai

Somsri

Somsak

Somying

Page 13: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassStudent

Somchai

Somsri

Somsak

Somying

Page 14: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassTennis Player

Paradorn

Venus

Marat

Martina

Page 15: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassInstitute

Social Technology

Engineering

Science

Agricultural Technology

Page 16: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class• Template• Name• Attributes• Operations• Responsibilities

Page 17: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class

Name

Attributes

Operations

Responsibilities

Page 18: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassStudent

StudentIDFirstNameLastNameAddressetc…RegisterForCourseDropCourseetc...

Page 19: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassTennis Player

FirstNameLastNameNationalityRankingetc…RegisterForTournamentetc...

Page 20: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassCar

Car Reg. NumberMakerModelColoretc…AccelerateStopetc...

Page 21: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

ClassAirplane

Plane NumberManufacturerModeletc…TakeOffLandingetc...

Page 22: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object & ClassStudent

Somchai

Somsri

Somsak

Somying

Page 23: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object & ClassStudent

Somchai

Somsri

Somsak

Somying

StudentStudentIDFirstNameLastNameAddressetc…

RegisterForCourseDropCourseetc...

Page 24: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object & ClassStudent

Somchai

Somsri

Somsak

Somying

Student1B4555555SomchaiSaetung7146 Suranivet 7etc…

RegisterForCourseDropCourseetc...

Page 25: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Student1B4555555SomchaiSaetung7146 Suranivet 7etc…RegisterForCourseDropCourseetc...

StudentStudentIDFirstNameLastNameAddressetc…RegisterForCourseDropCourseetc...

Page 26: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object-Oriented Concept

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

Page 27: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Inheritance

Animal

Dog PersonCat

Page 28: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Inheritance

Land Vehicle

Truck CarBus

Page 29: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Inheritance

Transaction

Rental Transaction

Lease Transaction

Sales Transaction

Page 30: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

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

Page 31: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

InheritanceLand Vehicle

Car

Toyota

TruckBus

Vios Altis Camry

Page 32: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

TransactiontransNotransDatetransTimeetc…

Rental Transaction

Lease Transaction

Sales TransactiontransNotransDatetransTimeetc…quantitySold…

transNotransDatetransTimeetc…memberNo…

transNotransDatetransTimeetc…duration…

Page 33: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object-Oriented Concept

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

Page 34: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Polymorphism

DrawChart

DrawChart(1)

DrawChart(1,2,1,2)

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

DrawRect(1,2,1,2)

DrawCircle(1)

Page 35: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

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”) ?

Page 36: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Polymorphism

:PaySlip

:HourlyPaidEmployee

:WeeklyPaidEmployee

:MonthlyPaidEmployee

getTotalPay()

calculatePay()

calculatePay()

calculatePay()

Page 37: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Polymorphism• Overloading

Page 38: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object-Oriented Concept

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

Page 39: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Encapsulation• Abstraction• Information Hiding• Security

Page 40: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

EncapsulationStudent

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

Page 41: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Encapsulation

Person Vending Machine

Buy Pepsi

Sell (10 Baht, Pepsi)

Sell

Page 42: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Object-Oriented Concept

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

Page 43: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship• Association• Aggregation• Composition• Generalization

Page 44: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship• Association

Pilot Planes

Page 45: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship

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

Page 46: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship• Composition

Car

Seat WheelEngine

Page 47: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship• Composition

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

Page 48: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship• Aggregation

Classroom Student

Page 49: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship

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

Page 50: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship• Generalization

Land Vehicle

Truck CarBus

Page 51: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Class Relationship• Generalization

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

Page 52: ซอฟต์แวร์พัฒนาระบบฐานข้อมูล บทที่  8 Object-Oriented Software Design

Introduction to Object-Oriented Software Design