1 objectives to introduces the concept of software design. to introduces the concept of software...

33
1 Objectives Objectives To introduces the concept of To introduces the concept of software Design. software Design. To introduce the concept of To introduce the concept of Object-Oriented Design (OOD). Object-Oriented Design (OOD). To Define various aspects about To Define various aspects about object modeling. object modeling.

Post on 20-Dec-2015

219 views

Category:

Documents


2 download

TRANSCRIPT

11

ObjectivesObjectives

To introduces the concept of To introduces the concept of software Design.software Design.

To introduce the concept of Object-To introduce the concept of Object-Oriented Design (OOD).Oriented Design (OOD).

To Define various aspects about To Define various aspects about object modeling.object modeling.

22

Software DesignSoftware Design

Design is an abstracted representation of Design is an abstracted representation of a system that captures its constituting a system that captures its constituting parts.parts.

Transformation of the analysis model into Transformation of the analysis model into a more concrete model.a more concrete model.

Decomposition of a system into sub-Decomposition of a system into sub-systems based on the analysis model of systems based on the analysis model of problem domain.problem domain.

33

Software DesignSoftware Design

Is a problem-solving activityIs a problem-solving activity• You will investigate possible options to You will investigate possible options to

met specs.met specs.• Evaluate solutions and make decisions.Evaluate solutions and make decisions.

44

Software Design AttributesSoftware Design Attributes

AbstractionAbstraction• Identify the important parts and ignore the Identify the important parts and ignore the

unnecessary details.unnecessary details. SimplicitySimplicity

• Avoid function or method complexity (single Avoid function or method complexity (single service)service)

Decomposition & ModularityDecomposition & Modularity• Replaceable and re-usable.Replaceable and re-usable.

CouplingCoupling• Interaction among modules.Interaction among modules.

CohesionCohesion• Degree of association within a module.Degree of association within a module.

EncapsulationEncapsulation• Hide module’s properties and control their accessibility.Hide module’s properties and control their accessibility.

55

Goals of software designGoals of software design

CorrectnessCorrectness• Software design must satisfy the requirements for the Software design must satisfy the requirements for the

application.application. RobustnessRobustness

• Able to handle miscellaneous and unusual conditions such as Able to handle miscellaneous and unusual conditions such as bad data, user error, programmer error, and environmental bad data, user error, programmer error, and environmental conditions.conditions.

FlexibilityFlexibility• Separation of interface and implementation.Separation of interface and implementation.

ReusabilityReusability EfficiencyEfficiency

• Only use the available resources.Only use the available resources. ReliabilityReliability

• It is relatively bug free.It is relatively bug free. UsabilityUsability

• Easy user interfaceEasy user interface

66

A checklist for checking some of A checklist for checking some of the goals of software designthe goals of software design

How can we tell from the code that all required How can we tell from the code that all required functionality has been handled? (functionality has been handled? (correctnesscorrectness))

If the user makes a mistake, does the system If the user makes a mistake, does the system crash or perform unpredictably (crash or perform unpredictably (robustnessrobustness))

Is the system hard to modify, add or remove Is the system hard to modify, add or remove parts? (parts? (flexibilityflexibility))

Does the system execute fast enough? (Does the system execute fast enough? (speedspeed efficiencyefficiency))

Does the system satisfy memory requirements? Does the system satisfy memory requirements? ((spacespace efficiencyefficiency))

Are the class usable for other applications? Are the class usable for other applications? ((reusabilityreusability))

77

OO DesignOO Design

Object-oriented design is concerned with developing an object-oriented model of a software system to implement the identified requirements.

An object is an entity that has a state and a defined set of operations which operate on that state.

Objects are created according to a class definition.• Is an instance of class.

88

Weather system descriptionWeather system description A weather mapping system is required to generate

weather maps on a regular basis using data collected from remote, unattended weather stations and other data sources such as weather observers, balloons and satellites. Weather stations transmit their data to the area computer in response to a request from that machine.

The area computer system validates the collected data and integrates it with the data from different sources. The integrated data is archived and, using data from this archive and a digitised map database a set of local weather maps is created. Maps may be printed for distribution on a special-purpose map printer or may be displayed in a number of different formats.

99

OO Design ProcessOO Design Process

The principal activities in any OO The principal activities in any OO design process include:design process include:• Define the context and modes of use of Define the context and modes of use of

the system.the system.• Design the system architecture.Design the system architecture.• Identify the principal system objects.Identify the principal system objects.• Develop design models.Develop design models.• Specify object interfaces.Specify object interfaces.

1010

System Context: A static model describes System Context: A static model describes other systems in the environment. Use a other systems in the environment. Use a subsystem model to show other systems.subsystem model to show other systems.

A model of use: A dynamic model A model of use: A dynamic model describes how the system interacts with describes how the system interacts with its environment. Use use-cases to show its environment. Use use-cases to show interactions.interactions.

Both are complementary and necessary to Both are complementary and necessary to develop an understanding of the develop an understanding of the relationships between the software being relationships between the software being designed and its external environment.designed and its external environment.

Context & Model of useContext & Model of use

1111

System Context ExampleSystem Context Example

Datastorage

Userinterface

«subsystem»Data collection

«subsystem»Data processing

«subsystem»Data archiving

«subsystem»Data display

Weatherstation

Satellite

Comms

Balloon

Observer

Map store Data store

Datastorage

Map

Userinterface

Mapdisplay

Mapprinter

Datachecking

Dataintegration

1212

Use-case models are used to Use-case models are used to represent each interaction with the represent each interaction with the system.system.

A use-case model shows the system A use-case model shows the system features as ellipses and the features as ellipses and the interacting entity as a stick figure.interacting entity as a stick figure.

Use-case modelsUse-case models

1313

Use-case ExampleUse-case Example

Startup

Shutdown

Report

Calibrate

Test

1414

ArchitectureArchitecture

Once interactions between the Once interactions between the system and its environment have system and its environment have been understood, you use this been understood, you use this information for designing the system information for designing the system architecture.architecture.

1515

Example of ArchitectureExample of Architecture

Weather station

Manages allexternal

communications

Collects andsummarisesweather data

Package ofinstruments for raw

data collections

«subsystem»Data collection

«subsystem»Instruments

«subsystem»Interface

1616

Identify Identify ObjectsObjects

Identifying objects is the most difficult part Identifying objects is the most difficult part of object oriented design.of object oriented design.

There is no 'magic formula' for object There is no 'magic formula' for object identification. It relies on the skill, identification. It relies on the skill, experience and domain knowledge of experience and domain knowledge of system designers.system designers.

Object identification is an iterative Object identification is an iterative process. You are unlikely to get it right process. You are unlikely to get it right first time.first time.

1717

Approaches to identificationApproaches to identification Use a grammatical approach based on a natural Use a grammatical approach based on a natural

language description of the system.language description of the system.• Objects and attributes are nouns, operations or services

are verbs Base the identification on physical things in the Base the identification on physical things in the

application domain.application domain.• Application domain, Role, Events, Locations… etc Application domain, Role, Events, Locations… etc

Use a behavioural approach and identify objects Use a behavioural approach and identify objects based on what participates in what behaviour.based on what participates in what behaviour.

Use a scenario-based analysis to identify objects, Use a scenario-based analysis to identify objects, attributes and methods in each scenario.attributes and methods in each scenario.

1818

Design ModelsDesign Models

Design models show the objects and Design models show the objects and classes and relationships between these classes and relationships between these entities.entities.

Static models describe the static structure Static models describe the static structure of the system in terms of classes and of the system in terms of classes and relationships at development-time.relationships at development-time.

Dynamic models describe the dynamic Dynamic models describe the dynamic interactions between objects at run-time.interactions between objects at run-time.

1919

Design ModelsDesign Models

identifier

reportWeather ()calibrate (instruments)test ()startup (instruments)shutdown (instruments)

WeatherStation

test ()calibrate ()

Groundthermometer

temperature

Anemometer

windSpeedwindDirection

test ()

Barometer

pressureheight

test ()calibrate ()

WeatherData

airTemperaturesgroundTemperatureswindSpeedswindDirectionspressuresrainfall

collect ()summarise ()

2020

Examples of design modelsExamples of design models Sub-system models that show logical Sub-system models that show logical

groupings of objects into coherent groupings of objects into coherent subsystems.subsystems.

Sequence models that show the sequence Sequence models that show the sequence of object interactions.of object interactions.

State machine models that show how State machine models that show how individual objects change their state in individual objects change their state in response to events.response to events.

Other models include use-case models, Other models include use-case models, generalisation models, specialisation generalisation models, specialisation models …etc.models …etc.

2121

Subsystem modelsSubsystem models

Shows how the design is organised Shows how the design is organised into logically related groups of into logically related groups of objects.objects.

In the UML, these are shown using In the UML, these are shown using packages - an encapsulation packages - an encapsulation construct. construct.

The UML annotation is used to label The UML annotation is used to label packages as sub-systems.packages as sub-systems.

2222

Example Example subsystemssubsystems

«subsystem»Interface

«subsystem»Data collection

CommsController

WeatherStation

WeatherData

InstrumentStatus

«subsystem»Instruments

Air thermometer

Ground thermometer

RainGauge

Barometer

Anemometer

WindVane

2323

Subsystem DecompositionSubsystem Decomposition Interface subsystemInterface subsystem

• Includes the objects in the system that are concerned Includes the objects in the system that are concerned with interfacing the “weather station” to external with interfacing the “weather station” to external systemssystems

• May include other objects from those shown here - e.g. a May include other objects from those shown here - e.g. a user interface for testing.user interface for testing.

Data collection subsystemData collection subsystem• Includes objects that implement the strategies adopted Includes objects that implement the strategies adopted

for data collectionfor data collection• These are deliberately separated from the actual data These are deliberately separated from the actual data

collection to allow for changes to these strategiescollection to allow for changes to these strategies Instruments subsystemInstruments subsystem

• Includes all objects that interface to the instrument Includes all objects that interface to the instrument hardwarehardware

2424

Sequence modelsSequence models

Sequence models show the sequence of Sequence models show the sequence of object interactions that take placeobject interactions that take place• Objects are arranged horizontally across the Objects are arranged horizontally across the

top.top.• Time is represented vertically so models are Time is represented vertically so models are

read top to bottom.read top to bottom.• Interactions are represented by labelled Interactions are represented by labelled

arrows, Different styles of arrow represent arrows, Different styles of arrow represent different types of interaction.different types of interaction.

• A thin rectangle in an object lifeline represents A thin rectangle in an object lifeline represents the time when the object is the controlling the time when the object is the controlling object in the system.object in the system.

2525

Data collection sequenceData collection sequence

:CommsController

request (report)

acknowledge ()report ()

summarise ()

reply (report)

acknowledge ()

send (report)

:WeatherStation :WeatherData

2626

Sequence of operationsSequence of operations

The sequence diagram shows:The sequence diagram shows:• An external entity, shown as a stick man, (it An external entity, shown as a stick man, (it

can be a person or another system) initiates can be a person or another system) initiates the data collection by sending a request to the the data collection by sending a request to the interface objectinterface object

• The interface object sends a request to the The interface object sends a request to the weather station to provide a report for weather station to provide a report for transmissiontransmission

• The weather station requests the WeatherData The weather station requests the WeatherData object which maintains all raw weather data to object which maintains all raw weather data to provide a summary that will be included in this provide a summary that will be included in this reportreport

2727

StatechartsStatecharts

Show how objects respond to Show how objects respond to different service requests and the different service requests and the state transitions triggered by these state transitions triggered by these requestsrequests

The states are represented as The states are represented as rounded rectanglesrounded rectangles

State transitions are labelled links State transitions are labelled links between these rectanglesbetween these rectangles

2828

Weather station state diagramWeather station state diagram

transmission done

calibrate ()

test ()startup ()

shutdown ()

calibration OK

test complete

weather summarycomplete

clock collectiondone

Operation

reportWeather ()

Shutdown Waiting Testing

Transmitting

Collecting

Summarising

Calibrating

2929

InterfacesInterfaces

Object interfaces have to be specified so Object interfaces have to be specified so that the objects and other components that the objects and other components can be designed in parallel.can be designed in parallel.

Designers should avoid designing the Designers should avoid designing the interface representation but should hide interface representation but should hide this in the object itself.this in the object itself.

Objects may have several interfaces which Objects may have several interfaces which are viewpoints on the methods provided.are viewpoints on the methods provided.

The UML uses class diagrams for interface The UML uses class diagrams for interface specification but Java may also be used.specification but Java may also be used.

3030

Weather station interfaceWeather station interface

interface WeatherStation {

public void WeatherStation () ;

public void startup () ;public void startup (Instrument i) ;

public void shutdown () ;public void shutdown (Instrument i) ;

public void reportWeather ( ) ;

public void test () ;public void test ( Instrument i ) ;

public void calibrate ( Instrument i) ;

public int getID () ;

} //WeatherStation

3131

Hiding information inside objects means that Hiding information inside objects means that changes made to an object do not affect other changes made to an object do not affect other objects in an unpredictable way.objects in an unpredictable way.

Assume pollution monitoring facilities are to be Assume pollution monitoring facilities are to be added to weather stations. These sample the added to weather stations. These sample the air and compute the amount of different air and compute the amount of different pollutants in the atmosphere.pollutants in the atmosphere.

Pollution readings are transmitted with weather Pollution readings are transmitted with weather data.data.

Design evolutionDesign evolution

3232

Pollution monitoringPollution monitoring

NODatasmokeDatabenzeneData

collect ()summarise ()

Air qualityidentifier

reportWeather ()reportAirQuality ()calibrate (instruments)test ()startup (instruments)shutdown (instruments)

WeatherStation

Pollution monitoring instruments

NOmeter SmokeMeter

BenzeneMeter

3333

Key pointsKey points Object-oriented development involves adopting an OO Object-oriented development involves adopting an OO

approach at all stages from specification through to approach at all stages from specification through to programmingprogramming

OO design involves designing the system using objects as OO design involves designing the system using objects as the fundamental abstraction and representing the system the fundamental abstraction and representing the system as an associated set of models.as an associated set of models.

The OO design process involves several stages - discussed The OO design process involves several stages - discussed here were Context, Architecture and Objects.here were Context, Architecture and Objects.

A range of different models may be produced during an A range of different models may be produced during an object-oriented design process. These include static and object-oriented design process. These include static and dynamic system models.dynamic system models.

Object interfaces should be defined precisely using e.g. a Object interfaces should be defined precisely using e.g. a programming language like Java.programming language like Java.

Object-oriented design potentially simplifies system Object-oriented design potentially simplifies system evolution.evolution.