What Is Object-Oriented Design? (Chapter 1). Software Development Life Cycle 1. Problem statement...

21
What Is Object-Oriented Design? (Chapter 1)
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    217
  • download

    3

Transcript of What Is Object-Oriented Design? (Chapter 1). Software Development Life Cycle 1. Problem statement...

What Is Object-Oriented Design?

(Chapter 1)

Software Development Life Cycle

1. Problem statement and requirements 2. Solution specification 3. Code design 4. Code implementation 5. Code testing and debugging 6. Code delivery 7. Code maintenance

New Focus

In previous courses you have mostly done just 4 and 5 (implementation and testing/debugging)

This course will add 2 and 3 (specification and design) using OOD.

What Is Design?

Design: an abstract description of how somethingis built.

Example: descriptions of a CD player:

1. Information level (ones and zeros) 2. Functional level (how it is used) 3. Physical level (what its parts are) - fig. 1-1

Block Diagram of a CD Player(fig. 1-1)

Laser control

Data Processor D/A Converter

ControllerLCD

Display

AudioOutpu

tInputPanel

Data Audio

Index Data

Another Example

Descriptions of a house:

1. Realtor point of view 2. Architect point of view 3. Materials science point of view

Each level or point of view must use ABSTRACTION.

Examples of abstraction are models and diagrams.

Abstraction

Abstraction is the process of hiding details about anobject while still describing its functionality.

The physical description of a CD player hides thedetails of its functional use.

The realtor's point of view of a house hides the detailsof the architectural point of view.

Any design, by necessity, must hide details.

Design Hierarchy Example

House

LivingRoom

DiningRoom

Kitchen Bathroom Bedroom 1 ...

FloorCovering

WallCovering

Shower?

Factors In Design Quality

Relative level of detail: should be appropriate for audience

Number of top-level components: 5 to 10 Depth of hierarchy: should be appropriate for

audience

Presenting Designs With Diagrams

Hierarchical block diagrams Data-flow diagrams (as in fig. 1-1) Class diagrams Message-trace diagrams State diagrams

Approaches to Design by Abstraction

Procedural oriented design (control oriented) -- see next slide

Data oriented design (of which object oriented design is an example)

Procedural Design of Screen Editor(fig. 1-2)

Control

Get NextCommand

RefreshDisplay

ProcessCommand

ReadInput

DetermineCommand

. . .

Procedural Design

In terms of modules, procedures, and data structures (machine oriented objects)

There is a specific linear order to what needs to be done

Control more important than data HOWEVER, most real world problems do not

conform to this model (consider business and game applications)

Often better to break up a problem by looking at data flow

Data-flow Diagram of a Compiler(fig. 1-3)

ParseTrees

TokenStream

SourceFile

SymbolTable

Object File

LexicalAnalysis

ParseTrees

Parser SymbolResolution

CodeGeneration

Passive vs. Active Data

Passive Data Numbers Strings Simple structures Real world data often more complex than this

Active Data: data elements which "know how to do things," to themselves and other elements (virtual computers in software)

Such active data elements are also called "objects"

Solar System as Objects (fig. 1-4)

Solar System

components:List

update()

Subsystem

position: Vectormass:Real

components:List

update()

Body

position: Vectorvelocity:Vector

mass:Real

update()

Simple Objects for a Solar-System Simulation

Object-Oriented Design (OOD)

Describes a solution to a problem in terms of active data elements or objects (application oriented rather than machine oriented)

An object is a composition of data and operations An object is like a "wrapper" around data,

providing functionality to it Objects with the same data types and operations

are grouped together in a class "Object" is sometimes used ambiguously to refer

to both classes and individual objects

Keys to Constructing an Object-Oriented Design

1)Understand what an object of each class can be and do (view objects anthropomorphically)

2)Understand the interaction of the different classes

3)Define the interactions in such a way that the details of the internal operations are hidden from outside classes

Viewing Objects Anthropomorphically

Look at objects as though they were people: They are "living" in that their properties can change

over time They are "intelligent" in that they can undertake

operations and in a sense "know" how to perform them

They have a variety of types: physical objects, relationships, abstractions

Interaction of Classes

Classes interact by:

1)Providing operations that can be invoked by other classes

2)Invoking other classes' operations in order to perform one's own

OOD provides abstraction by isolating information inside classes

A class interface is the set of operations and data the class makes available to other classes

The interface does not say how desired behavior is achieved

OOD Methodology

A Three-Step Process:

1) Identify the classes: Decide what the classes will be

2) Characterize the classes: Name each object and the data associated with it

3) Define the implementation: Define all of the operations using pseudocode