Top Banner
Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis
52

Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Lecture 5 Design

CS 540 – Quantitative Software Engineering

Architecture is synthesis

Design is analysis

Page 2: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Management is work!

“The techniques of communication and organization demand from the manager as much thought and as much experience and competence as the softwareitself.” - Brooks, p83

Page 3: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Key Word in Context index –a concordance

Generate n shifts where n is the number of words in a line.

Eliminate non keywords. Sort Lines in alphabetic order by keyword.

adapted from Parnas

Page 4: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Main Program with subroutines

Decompose tasks• Read & store input

• Eliminate ‘noise’ words

• Shift to keyword

• Sort the shifted lines

• Write the sorted lines

Page 5: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Main Program with Subroutines

Input Shift

Store Shifts Sorted

input

Sort Output

output

Control

Page 6: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Abstract Data types

Make data representation type decisions early Access data through procedures rather than

directly• Design stage only requires agreement about

procedure interface

• Changes in data can be made easily w/o affecting other modules

Page 7: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Abstract-data-type

Input Output

Control

SortShiftStore

outputinput

Page 8: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Implicit Invocation

Want to get rid of uninteresting shifts (or include only interesting shifts)

Could filter the data but it is inefficient Change the shift module - but we may be messing with it

too much Solution - we do not explicitly call make shift we generate

an EVENT.

Page 9: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Implicit-invocation

Input MakeShift Sort Output

Store Shiftinput output

Control

Page 10: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Pipes and filters

Good old UNIX Since each program reads it input in same order

we can use pipes and filters But Error handling is primitive as UNIX uses

separate error channel.

Page 11: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Pipes-and-Filters

Input Shift Sort Output

input output

Page 12: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Evaluation of these architectures

All work Differences become apparent if we evaluate them

on some criteria.

Page 13: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Evaluation

Shared data

Abstract data type

Implicit invocation

Pipe and filter

Changes data representation

- + + -

Independent dev - + + +

Comprehensibility - + o +

Performance + + - -Reuse - + + +

Page 14: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Component Types

Type Description

computational Does a computation or operation or I/O.

memory Persistent data structure, shared by components - file

manager State and associated operators. Operations use or update state, state retained - abstract data types

controller Governs time sequence of events - scheduler

Page 15: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Reality

In practice there is usually a mixture of architectural styles.

Page 16: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Design Patterns

Recurring structure of communicating components

Micro architectures Differs from architectural style in scope, not

structure

Page 17: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Pattern Attributes

Different ‘look and feel’ must not impact application code

Capture well-proven design experience Capture meta abstractions beyond a component Document, describe and prescribe

Page 18: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Quality of design metrics

• Abstraction,• Modularity, • Information hiding, • Coupling • System structure

Page 19: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Yourdon and Constantine, 7 (+1) levels of Cohesion

Levels are of increasing strength:• Coincidental- modules grouped in haphazard way, no relation• Logical - logically related tasks that do not call each other or

pass data between each other - all output routines• Temporal - various independent components activated at same

time - initialization• Procedural- group of components executed in a set order• Communicational - components operate on the same temporal

data• Sequential- output of one serves as input to another• Functional all components contribute to a single function in the

module• + data - modules that encapsulate an abstract data type

Page 20: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Coupling

Tightest to loosest (worst to best):• Content- one module controls another’s execution

• Common- modules share data

• External modules communicate through external media (a file)

• Control - one module directs execution of another by passing necessary control information via flags

• Stamp - complete data structures are passed from one to another

• Data only -single data item passed between modules

Page 21: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Coupling and cohesion

Advantages of low coupling, high cohesion:• Communication between developers is easier

• Correctness proofs are easy to derive and sustain

• Changes will not affect other modules, lower maintenance costs

• Reusability is increased

• Understanding increase

• Empirical data shows less errors.

Page 22: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Complexity

Attributes of the software that affect effort needed to construct or change a piece of software

2 classes of complexity metrics• Size based - KLOC

• Structure based - complicated control or data structures

Halstead and McCabe

Page 23: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

System Structure

Types of intermodule relations such as A contains B, A follows B, A delivers data to B, A uses B

The amount of knowledge each uses about the other should be kept to a minimum• Information flow should be limited to procedure calls - no

Common data structures

Graph depicting procedure calls is a call graph - we can measure attributes related to the shape of the call graph

Page 24: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Module Hierarchies

Directed graph Directed non-cyclic graph

Layered graph Tree

Page 25: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Graph analysis

Some measures:• Size - number of nodes and edges• Depth - longest path from root to leaf• Width - maximum nodes at some level

A good design should have a tree-like call graph• One measure of complexity is to assess tree impurity• Remove edges until you get a tree• Tree impurity = # of extra edges / maximum # of extra edges• If 0 graph is a tree, if 1 it is a complete graph• But trees are not always desirable, does not permit reuse

Fan in fan out measures indicates spots deserving attention, e.g., if a module has high fan in it may indicate little cohesion, excessive increase in information flow from one level to next may indicate missing level of abstraction

Page 26: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Design Heuristics for Modularity(Pressman)

Evaluate the first iteration of a program structure to reduce coupling and improve cohesion

Attempt to minimize structures with high fan out; strive for high fan in as depth increases

Keep the scope of effect of a module within the scope of control of that module

Evaluate module interfaces to reduce complexity and redundancy and improve consistency

Define modules whose function is predictable, but avoid modules that are overly restrictive

Strive for controlled entry modules by avoiding pathological conditions (branches or references into the middle of a module)

Page 27: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Design Methods

Functional decomposition Data flow design - functional decomposition with

respect to flow of data. Component is a black box transforming some input stream to an output stream

Design based on data structures - given a correct model of data structures, design of the program is straightforward

Object-oriented design

Page 28: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Functional Decomposition

Intended function decomposed into sub functions and continues downward

Start from user end it is top-down, primitives, bottom-up Parnas method:

• Identify sub systems, start with a minimal subset and define minimal extensions (incremental development)

• Apply information hiding principles• Define extensions step by step• Apply uses relation and try to develop a hierarchy• Layered approach, use only components at the same

or lower level

Page 29: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

View on DesignDesign View Description Attributes User Roles

Decomposition Decomp of system into modules

Identification, type, purpose, function, subcomponents

Project manager

Dependencies Relations between modules and resources

Identification, type, purpose, dependencies, resources

Configuration manager, maintenance programmer, integration tester

Interface How to use modules

Identification, function, interfaces

Designer, Integration tester

Detail Internal details of modules

Identification, computation, data

Module tester, programmer

Page 30: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Architecture in a Project’s Life Cycle

Discovery

Planning and

ArchitectureReview

Review

Carries through thelife of the project

Iterative processuntil consensusis reached

Architecture PhaseProspectus

Requirements

Architecture

HighLevelDesign

LowLevelDesign

It encompasses the requirements, architecture and high level design phases of thetypical waterfall diagram. It also continues throughout the life of the project(someone continues to wear the architect’s hat).

Page 31: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

What is an Architecture Description Language?

Describe high-level designs

Treats systems as collections of connected modules

• Module layout defines structure

• Connectors define communication

• Interfaces are modules

Does NOT describe algorithms, data structures or control flows

Page 32: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Cost of Modifying Modules for Reuse -- NASA Data for 2954 Modules

0

0.2

0.4

0.6

0.8

1

1.2

0 0.25 0.5 0.75 1

Usual LinearAssumption

Real Cost

Amount Modified

RelativeCost

Page 33: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

OO Analysis and Design

Traditional techniques focus on functions of the system OO focuses on identifying and interrelating the objects

that play a role in the system Convergence to UML, Unified Modeling Language,

Booch, Jacobson and Rumbaugh Heuristic thoughts- keep objects simple and each method

should send messages to objects of a very limited set of classes (more when we explore OO metrics)

Page 34: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

“Schools” of OO

European school, influenced by the Scandinavian school of Programming, OO analysis and design is modeling real world objects both animate and inanimate

American school, OO focuses on data abstraction and component reuse - identifying reusable components and building an inheritance hierarchy.

“What matters is not how closely we model today’s reality but how extensible and reusable our software is”

Page 35: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

OO views

Modeling view - conceptual model of some part of a real or imaginary world.

Object = identity + state + behavior Philosophical view - objects are existential

abstractions and if not instantiated they cannot be changed

Software Engineering view - data abstractions encapsulate data and operations

Page 36: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

OO views - 2

Implementation view• Continuous structure in memory, a record of data and code

elements

Formal viewpoint• Object viewed as a state machine with a finite set of states and a

finite set of state functions. State functions map old states and inputs to new states and inputs

Tensions exist betweenthe problem oriented (architecture) and the solution oriented view (design).

Page 37: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

OO Analysis and Design schemes

Common notations of the schemes:• Class diagram - static depiction of objects as nodes and their relations

as edges• State diagram - models dynamic behavior of single objects using a

variant of a finite state machine representation. Nodes in state diagram represent state of object, edges possible transitions between states

• Interaction diagrams - model sequence of messages in an interaction among objects

» Sequence diagrams emphasize time orderings» Collaboration diagrams emphasize objects and their relationships relevant to

a particular interaction

Page 38: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

The Class Diagram

Shows the static structure which are elements of the model, usually classes, and relationships between them

Class diagram also represents subclass-superclass hierarchy - a hollow triangle indicates a generalization specialization relationship

Class boxes have 3 parts: name of object, list of attributes and list of services

UML permits indicating semantic constraints between classes {}

• Disjoint constraint indicates that a descendant may not be descended from more than one of the superclasses

• Overlapping constraints indicate that it may

Page 39: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Object hierarchy (12.2)furniture

table chair

HighChairEasyChair

Page 40: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

State Diagram

Depict sequence of states an object progresses through

Have local variables and output actions that may be associated with both transitions and states

“Statesmanship”• A state is some condition in the life of an object

• A change in state causes a transition to fire

• Transition labeled by transition string

• States may be nested for ease of exposition

Page 41: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

State Diagram

is-member cleaning-up

Start/N:=0

Rent/N:=N+1

Return/N:=N-1

Stop[N=0]

End

Page 42: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Sequence Diagram

Shows time ordering of messages Diagrams can become quite elaborate showing

asynchronous and synchronous message passing, indicate iteration, …

Page 43: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Sequence Diagram (12.9)

user reservationscatalog1:lookup

2: item name

3: [not available]reserve

4: item returned

5: hold item

5: item available

6: borrow item

6: remove reservation

Page 44: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Avionics ADL

Specification of• Real-time

• Embedded

• Fault-tolerant

• Securely partitioned

• Dynamically configurable

Software task and communication architectures Bound to distributed multiple processor hardware

architectures

Page 45: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Architecture-based Requirements

Analysis

Architecture-based Design and

Implementation

Architecture-based System Integration

Model-Based AADL Process

Rapid Integration Predictable System Upgradeability

Explicit ArchitectureEngineering Model

Page 46: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Navigation

WarheadFusing

Communi-cation& ProtocolTelemetry

Sensor& SignalProcessing

SoftwareEngineer

Real-Time Architecture ModelSoftware Hardware

System Build• Executive Generation• Module Integration•Nmake

DomainSpecific

Hardware

MemoryConfiguration

BusDesign

ProcessorArchitecture

Model-Based AADL Engineering

Generated Components

Generated Components

Generated Components

AutomaticTargetRecognition

Guidance& Control

Domain Specific Languages

Hand Coded Components

Hand Coded Components

Analyses• Schedulability• Reliability• Fault Tolerance

Page 47: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Generated Partitioned Architecture

Strong Partitioning • Timing Protection• OS Call Restrictions• Memory Protection

Portability• Application Components• Tailored MetaH Executive• MetaH Kernel

Operating Environment

Software Component

Software Component

Software Component

Embedded Hardware Target

SoftwareComponent

MetaH Executive

MetaH Kernel

Fault Recovery, Execution Control, Mode Control, Timing Control, Data Synchronization,

Interprocess Communication

Page 48: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

UML Extensions

UML core concepts can be extended or specialized by users

• Three built-in extension mechanisms

»Stereotype

»Constraint

»Tagged Value

Page 49: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Key Design Constraints

Limit the language features Insist on Structured Programming Modularity and Componentry Provide Fault Containment and Recovery Restrict Module Size Perform scenario tests

Page 50: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Probably the most significant step forward in defect removal prior to delivery which we have yet experienced The evidence suggests that they are 5-10 times more efficient

than any other form of defect removal.

The technology is mature, (some 20 years old), and in trained hands, exceptionally effective.

Inspections

Page 51: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Conditions That Cause Software Instability

Poor Algorithms Missing Deadlines Round-off Error Build Up Memory Leaks Broken Pointers Register Misuse

Page 52: Lecture 5 Design CS 540 – Quantitative Software Engineering Architecture is synthesis Design is analysis.

Software Rejuvenation

Instead of running a system for a year, run it for one day 365 times

-- Periodic preemptive rollback of continuously running applications prevents future

failures.

-- Gracefully terminating an application allows restarting at a known and clean internal

state.