Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scott Grissom, copyright 2004Ch 2 OO Design Slide 1 Object Oriented Design Chapter 2 focuses on: objects, classes inheritance polymorphism UML class diagrams.

Similar presentations


Presentation on theme: "Scott Grissom, copyright 2004Ch 2 OO Design Slide 1 Object Oriented Design Chapter 2 focuses on: objects, classes inheritance polymorphism UML class diagrams."— Presentation transcript:

1 Scott Grissom, copyright 2004Ch 2 OO Design Slide 1 Object Oriented Design Chapter 2 focuses on: objects, classes inheritance polymorphism UML class diagrams OO Design Allows us to design solutions in a more natural way using the language of the problem domain

2 Scott Grissom, copyright 2004Ch 2 OO Design Slide 2 Objects State internal values Behavior methods Identity unique spot in memory object references multiple refs possible State & Behavior of traffic light elevator car

3 Scott Grissom, copyright 2004Ch 2 OO Design Slide 3 Object-oriented Design (2.3) a creative process requires intuition & experience multiple solutions compare strengths & weaknesses Program Specifications what needs to be built? Responsibilities & Relationships who does what? supermarket employees, football team Mary and Tom work together in an office Identify objects, actions look for nouns and verbs See examples in the book

4 Scott Grissom, copyright 2004Ch 2 OO Design Slide 4 Identify relationships “is a” inheritance or generalization a car is a vehicle extends a class “has a” association a car has an engine contains instance variables “uses” dependency a car uses gasoline has local variables “realization” implements an interface

5 Scott Grissom, copyright 2004Ch 2 OO Design Slide 5 A Good Design… Objects have high cohesion Objects are loosely coupled Resembles a collection of interacting entities Objects have unique responsibilities and collaborate with other objects Can be modifed easily in response to future demands

6 Scott Grissom, copyright 2004Ch 2 OO Design Slide 6 Inheritance (2.2.3) Take advantage of things that are similar to each other Quick way to use existing classes Plastic dolls Barbie Skipper Ballet barbie Gymnast barbie GI Joe became Ken

7 Scott Grissom, copyright 2004Ch 2 OO Design Slide 7 Inheritance Inheritance allows us to derive a new class from an existing one The existing class is called the parent class, or superclass The derived class is called the child class or subclass. The child class inherits the methods and data defined for the parent class

8 Scott Grissom, copyright 2004Ch 2 OO Design Slide 8 Class Hierarchies A child class of one parent can be the parent of another child, forming class hierarchies It is almost an ‘art’ to design an appropriate hierarchy Common characteristics should be grouped together in the parent class Group Exercise sausage, scrambled eggs toast, muffins orange juice, milk bacon, cereal pancakes, fried eggs

9 Scott Grissom, copyright 2004Ch 2 OO Design Slide 9 UML Class Diagrams (2.3.2) UML notation unified modeling language graphical notations (blueprint) conveys key design concepts 9 diagrams class diagrams disregard sequence diagrams Classes name optional instance variables optional methods Relationships inheritance - solid line with triangle association - solid line with arrow dependency - dashed line with arrow realization - dashed line with arrow Automobile example Book Examples (2.3, 2.4) Group Activity draw a class diagram starting with a desktop computer

10 Scott Grissom, copyright 2004Ch 2 OO Design Slide 10 Group Activities Brainstorm components behavior relationships A voice mail system Solitaire game Student juke box


Download ppt "Scott Grissom, copyright 2004Ch 2 OO Design Slide 1 Object Oriented Design Chapter 2 focuses on: objects, classes inheritance polymorphism UML class diagrams."

Similar presentations


Ads by Google