520 likes | 636 Views
การออกแบบและพัฒนาซอฟต์แวร์ บทที่ 8 Object-Oriented Software Design. ปริญญา น้อยดอนไพร สาขาวิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยราช ภัฏ สุราษฎร์ธานี. Object-Oriented Software Design. Object-Oriented Concept Introduction to Object-Oriented Software Design.
E N D
การออกแบบและพัฒนาซอฟต์แวร์บทที่ 8 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
Object-Oriented Concept • Object & Class • Inheritance • Polymorphism • Encapsulation • Class Relationship
Object • Object World • Message • Method/Operation • Interface • Event • Responsibilities
Click ( ) Object
Deliver (Mail) Object Person Post Office Deliver Send Mail
Sell (10 Baht, Pepsi) Object Person Vending Machine Sell Buy Pepsi
MoveToFloor (3) Object Person Elevator MoveToFloor Open Close Go to 3rd floor
Class Person Somchai Somsri Somsak Somying
Class Student Somchai Somsri Somsak Somying
Class Tennis Player Paradorn Venus Marat Martina
Class Institute Social Technology Engineering Science Agricultural Technology
Class • Template • Name • Attributes • Operations • Responsibilities
Student Somchai Somsri Somsak Somying Object & Class
Student Somchai Somsri Somsak Somying Object & Class
Object & Class Student Somchai Somsri Somsak Somying
Object-Oriented Concept • Object & Class • Inheritance • Polymorphism • Encapsulation • Class Relationship
Cat Dog Person Inheritance Animal
Bus Truck Car Inheritance Land Vehicle
Sales Transaction Rental Transaction Lease Transaction Inheritance Transaction
Inheritance • Class Hierarchy • Sub Class • Super Class • Reusability • Overriding
Bus Truck Inheritance Land Vehicle Car Toyota Vios Altis Camry
Sales Transaction Rental Transaction Lease Transaction transNo transDate transTime etc… quantitySold… transNo transDate transTime etc… memberNo… transNo transDate transTime etc… duration… Transaction transNo transDate transTime etc…
Object-Oriented Concept • Object & Class • Inheritance • Polymorphism • Encapsulation • Class Relationship
Polymorphism DrawChart(1,2,1,2) DrawRect(1,2,1,2) DrawChart DrawTriangle(1,1,1) DrawCircle(1) DrawChart(1,1,1) DrawChart(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 :HourlyPaidEmployee calculatePay() :PaySlip :WeeklyPaidEmployee getTotalPay() calculatePay() :MonthlyPaidEmployee calculatePay()
Polymorphism • Overloading
Object-Oriented Concept • Object & Class • Inheritance • Polymorphism • Encapsulation • Class Relationship
Encapsulation • Abstraction • Information Hiding • Security
Sell (10 Baht, Pepsi) Encapsulation Person Vending Machine Sell Buy Pepsi
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 Engine Seat Wheel
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
Bus Truck Car Class Relationship • Generalization Land Vehicle