













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














Object-Oriented Design
Improve software design Reduce implementation effort Scalable to large software projects Try to take advantage of two techniques Abstraction Encapsulation
Encapsulation
Always abstract data & function together Encapsulated entity
Abstract Data Type (ADT)
List ADT May be implemented as array, linked list, etc… Java collections library
Benefits of Encapsulation
Due to information hiding
Interface to data structure clearly defined Easier to reuse code
Object-Oriented View
Thermostat uses dial setting to control a heater tomaintain constant temperature in room Room Thermostat (dial) Heater getTemperature() heaterOn()
History of Object-Oriented Design Preceded by procedure-oriented view Earliest approach to programming Uses procedure abstraction Similar to actual machine instructions Focus on control flow, program scope Examples: Fortran, Cobol, Pascal, Basic
Thermostat()1. Get room temperature
If (temperature < setting) turn heater on
Else turn heater off
Goto step 1
Factors in Success of OO Design
More experience with large software projects
Made OO programming easier
Support more language features efficiently
Handled inefficiencies in OO programming Made performance less critical
Elements of Object-Oriented Design^ Objects Entities in program
Functions associated with objects
Groups of objects with similar properties
Relationship between classes
Object Example
State DesiredTemp CurrentTemp HeaterState Behavior SetDesiredTemp() TurnHeaterOn() TurnHeaterOff() Identity this
Object Example
State Property Value DesiredTemp integer
o CurrentTemp integer
o HeaterState boolean
Object Behavior
Procedures associated with object
myThermostat.setDesiredTemp(78) myThermostat.turnHeaterOn() myThermostat.turnHeaterOff()
Method Types
Return state information
Modify state information
Create & initialize new object
Remove object & free up resources
Reference Variables
Identity
Whether two objects are equal
Reference variables point to same object
Objects from same class State in each object are identical