Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦...

33
Software Design Software Design Process Process A solution to satisfy the requirements Design process and methods Design strategies including object- oriented design and functional decomposition Design quality attributes Reference: Software Engineering , by Ian Sommerville Modified by Dan Li, 2012

Transcript of Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦...

Page 1: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Software Design Software Design ProcessProcess

A solution to satisfy the requirements◦ Design process and methods

◦ Design strategies including object-oriented design and functional decomposition

◦ Design quality attributes

Reference: Software Engineering, by Ian SommervilleModified by Dan Li, 2012

Page 2: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Design processDesign processAny design may be modelled as a directed

graph made up of entities with attributes which participate in relationships

The system should be described at several different levels of abstraction

Design takes place in overlapping stages. It is artificial to separate it into distinct phases but some separation is usually necessary

Page 3: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

From informal to formal From informal to formal designdesign

Informaldesignoutline

Informaldesign

Moreformaldesign

Finisheddesign

Page 4: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Phases in the design processPhases in the design process

Architecturaldesign

Abstractspecificatio

n

Interfacedesign

Componentdesign

Datastructuredesign

Algorithmdesign

Systemarchitecture

Softwarespecification

Interfacespecification

Componentspecification

Datastructure

specification

Algorithmspecification

Requirementsspecification

Design activities

Design products

Page 5: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Design phasesDesign phases

Architectural design Identify sub-systemsAbstract specification Specify sub-systems Interface design Describe sub-system

interfacesComponent design Decompose sub-systems

into componentsData structure design Design data structures

to hold problem dataAlgorithm design Design algorithms for

problem functions

Page 6: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Hierarchical design structureHierarchical design structure

System level

Sub-systemlevel

Page 7: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Top-down designTop-down design In principle, top-down design involves

starting at the uppermost components in the hierarchy and working down the hierarchy level by level

In practice, large systems design is never truly top-down. Some branches are designed before others. Designers reuse experience (and sometimes components) during the design process

Page 8: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Design methodsDesign methodsStructured methods are sets of notations

for expressing a software design and guidelines for creating a design

Well-known methods include Structured Design (Yourdon), and JSD (Jackson Method)

Can be applied successfully because they support standard notations and ensure designs follow a standard form

Structured methods may be supported with CASE tools

Page 9: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Method componentsMethod componentsMany methods support comparable views of

a system

A data flow view (data flow diagrams) showing data transformations

An entity-relation view describing the logical data structures

A structural view showing system components and their interactions

Page 10: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Method deficienciesMethod deficienciesThey are guidelines rather than

methods in the mathematical sense. Different designers create quite different system designs

They do not help much with the early, creative phase of design. Rather, they help the designer to structure and document his or her design ideas

Page 11: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Design descriptionDesign descriptionGraphical notations. Used to display

component relationshipsProgram description languages. Based on

programming languages but with more flexibility to represent abstract concepts

Informal text. Natural language description.

All of these notations may be used in large

systems design

Page 12: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Design strategiesDesign strategiesFunctional design

◦The system is designed from a functional viewpoint.

◦The system state is centralised and shared between the functions operating on that state

Object-oriented design◦The system is viewed as a collection of

interacting objects. ◦The system state is de-centralised and each

object manages its own state. Objects may be instances of an object class and communicate by exchanging messages

Page 13: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Functional view of a Functional view of a compilercompiler

AnalyseBuild

symboltable

Scansource

Generatecode

Symboltable

Outputerrors

Sourceprogram

Tokens Tokens Syntaxtree

Objectcode

ErrorindicatorSymbols Symbols

Errormessages

Page 14: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Object-oriented view of a compilerObject-oriented view of a compiler

Sourceprogram

Tokenstream

Symboltable

Syntaxtree

Grammar Errormessages

Abstractcode

Objectcode

Scan Add

CheckGet

Build Print

Generate

Generate

Page 15: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Mixed-strategy designMixed-strategy designAlthough it is sometimes suggested that

one approach to design is superior, in practice, an object-oriented and a functional-oriented approach to design are complementary

Good software engineers should select the

most appropriate approach for whatever sub-system is being designed

Page 16: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Design qualityDesign qualityDesign quality is an elusive concept. Quality

depends on specific organisational priorities.A 'good' design may be the most efficient, the

cheapest, the most maintainable, the most reliable, etc.

The attributes discussed here are concerned with the maintainability of the design.

Quality characteristics are equally applicable to function-oriented and object-oriented designs.

Page 17: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

CohesionCohesionA measure of how well a component 'fits

together'A component should implement a single

logical entity or functionCohesion is a desirable design

component attribute as when a change has to be made, it is localised in a single cohesive component

Various levels of cohesion have been identified.

Page 18: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Cohesion levelsCohesion levels

Coincidental cohesion (weak)◦ Parts of a component are simply bundled together

Logical association (weak)◦ Components which perform similar functions are

grouped◦ For example:output text to screen

output line to printer

output record to file

◦ Seems ok ◦ Problem is it carries out a range of similar but

different actions ◦ No single well defined action

Page 19: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Cohesion levelsCohesion levelsTemporal cohesion (weak)

◦Components which are activated at the same time are grouped

◦For example:clear screenopen fileInitialise total

◦again not related ◦solution is to make initialisation module all

other specialised modules: call init_terminal call init_files call init_calculations

Page 20: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Cohesion levelsCohesion levelsProcedural cohesion (weak)

◦The elements in a component make up a single control sequence

Communicational cohesion (medium)◦All the elements of a component

operate on the same data◦e.g. display and log temperature

Sequential cohesion (medium)◦The output for one part of a component

is the input to another part

Page 21: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Cohesion levelsCohesion levelsFunctional cohesion (strong)

◦optimal type of cohesion ◦performs a single well-defined action on a

single data object ◦e.g. calculate average ◦Each part of a component is necessary for

the execution of a single functionObject cohesion (strong)

◦Each operation provides functionality which allows object attributes to be modified or inspected

Page 22: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Cohesion as a design Cohesion as a design attributeattributeNot well-defined. Often difficult to classify

cohesionInheriting attributes from super-classes

weakens cohesionTo understand a component, the super-

classes as well as the component class must be examined

Object class browsers assist with this process

Page 23: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

CouplingCouplingA measure of the strength of the inter-

connections between system componentsLoose coupling means component changes

are unlikely to affect other componentsShared variables or control information

exchange lead to tight couplingLoose coupling can be achieved by state

decentralisation (as in objects) and component communication via parameters or message passing

Page 24: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Tight couplingTight coupling

Module A Module B

Module C Module D

Shared dataarea

Page 25: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Loose couplingLoose coupling

Module A

A’s data

Module B

B’s data

Module D

D’s data

Module C

C’s data

Page 26: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Coupling levelsCoupling levelsAltering another modules code (LISP,

Assembler) Modifying data within another module

◦fault that appears in one module may be due to another

◦complicated understanding and debugging

◦can be done via global variables or pointers or call be reference in C++ / Java

Shared or global data

Page 27: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Coupling levelsCoupling levelsProcedure call with a parameter that is a

switch (or a function pointer in C) ◦io (command, device buffer, length); ◦where command is 0,1,2 for read, write open;

better to use ◦read( device, buffer, length);

Procedure call with parameters that are pure data ◦ ideal is call by value, where a small number of

parameters are used and a copy of the data is passed to the procedure invoked

◦clear what information is being communicated

Page 28: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Coupling levelsCoupling levelsPassing a serial data stream

◦most ideal situation◦one module passes stream of data to

another◦once passed data is outside control of

process/module◦like piping in UNIX◦data can be thought of as a temporary

intermediate file◦only possible in languages that support

concurrency such as Ada and Erlang and Parallel C

Page 29: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Coupling and inheritanceCoupling and inheritanceObject-oriented systems are loosely

coupled because there is no shared state and objects communicate using message passing

However, an object class is coupled to its super-classes. Changes made to the attributes or operations in a super-class propagate to all sub-classes. Such changes must be carefully controlled

Page 30: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

UnderstandabilityUnderstandabilityRelated to several component

characteristics◦Cohesion. Can the component be understood

on its own?◦Naming. Are meaningful names used?◦Documentation. Is the design well-

documented?◦Complexity. Are complex algorithms used?

Informally, high complexity means many relationships between different parts of the design. hence it is hard to understand

Most design quality metrics are oriented towards complexity measurement. They are of limited use

Page 31: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

AdaptabilityAdaptabilityA design is adaptable if:

◦Its components are loosely coupled◦It is well-documented and the documentation

is up to date◦There is an obvious correspondence between

design levels (design visibility)◦Each component is a self-contained entity

(tightly cohesive)To adapt a design, it must be possible to

trace the links between design components so that change consequences can be analysed

Page 32: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Design traceabilityDesign traceability

P O R

D

A

B

F

C

D Object interactionlevel

Object decompositionlevel

Page 33: Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.

Adaptability and inheritanceAdaptability and inheritanceInheritance dramatically improves adaptability.

Components may be adapted without change by deriving a sub-class and modifying that derived class

However, as the depth of the inheritance hierarchy increases, it becomes increasingly complex. It must be periodically reviewed and restructured◦new trend in this area known as refactoring,

associated with the lightweight process of Extreme Programming (XP)