Presentation is loading. Please wait.

Presentation is loading. Please wait.

OO (Object Oriented) Programming Chapter 21 IB103 Week 12.

Similar presentations


Presentation on theme: "OO (Object Oriented) Programming Chapter 21 IB103 Week 12."— Presentation transcript:

1 OO (Object Oriented) Programming Chapter 21 IB103 Week 12

2 A method of Design, (make the major decisions first when designing programs) OO object oriented programs “Balloon” as an example, a simulation of a balloon Principles of OOP 1. Encapsulation (Chapter 9) 2. Inheritance (Chapter 11) 3. Polymorphism

3 Encapsulation …group related information together and protected from the outside (world) Private = protected or Open = open to the world

4 Inheritance Use classes repeatedly Reuse parts of existing classes when possible

5 Polymorphism Same methods used with others, multiple implementations

6 Design problems Need to identify objects. An approach to problem solving Simulation and Modeling Build a software model of something in the real world Identify the object(s) in the problem Model them as objects Ignore irrelevant detail Specification = what is required Design = how it will be accomplished

7 Model – view - controller An example: A cars engine (model) the observer = you gas pedal (controller) speedometer (some dial or gage) i.e. GUI What user adjusts with (a scrollbar (controller) as an example)

8 A Balloon example Model- car engine vs. Balloon View – speedometer vs. Circle Controller – steering wheel vs. change position of Balloon (left/right, up/down)

9 Hierarchy An old example “Sphere” class as the parent and Orb, or Circle, or marble or whatever as child. Many other sub classes possible Analyze the specifications of what you are to model (design) Write in pseudocode before using Java

10 Case study in design “One Armed Bandit” example “Slotmachine”: “Actions” Display Go Query Stop Reuse the components that your program can inherit

11 Relationships “is a” vs. “has a” Is a = inheritance (java “extends”) from parent class Has a = (java “new”) an object Needs a = utility (java various methods) need of another object, may pass in a parameter)

12 Reuse components that your program can inherit Save time, money Tested before Build library Specific to organisation


Download ppt "OO (Object Oriented) Programming Chapter 21 IB103 Week 12."

Similar presentations


Ads by Google