













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!














Overview
Goals Techniques Object-oriented view Examples
Techniques – Abstraction
Provide simple high-level model of Physical entity Activity
Can change implementation & representation Will not affect other software components
Types of Abstraction
Specify what actions should be performed Hide algorithms
Specify data objects for problem Hide representation
Techniques – Encapsulation
Confine information so it is only visible / accessiblethrough an associated external interface
For some entity
in program Abstract data in
Abstract actions on data in
Collect data & actions on
in same location Protects and hides
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
Object-Oriented Design
A collection of entities (objects) Functions associated with each object Communication between objects
Object-Oriented View
Thermostat uses dial setting to control a heater tomaintain constant temperature in room Room Thermostat (dial) Heater getTemperature() heaterOn()
OO Programming Languages
Simula (Dahl & Nygaard, 1962) Modeling discrete event simulation Smalltalk (Kay, 1972) General programming C++ (Stroustrup, 1979) Manage complexity in huge software projects Java (Gosling, 1991) Designed for embedded processors
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
Objects
Entity that has state, behavior, and identity State (data) Properties possessed by object Current values of those properties Behavior (methods) How objects react to changes in state How objects interact with each other Identity (references) Mechanism to distinguish between objects
Object Example
State DesiredTemp CurrentTemp HeaterState Behavior SetDesiredTemp() TurnHeaterOn() TurnHeaterOff() Identity this
Object State
Static, unchanging May view as types
Dynamic, changes Within bounds set by properties
Methods
Procedures associated with object
myThermostat.setDesiredTemp(78) myThermostat.turnHeaterOn() myThermostat.turnHeaterOff()