introduction the process of design involves “conceiving and planning out in the mind” and making...

50
PROGRAM DESIGN

Upload: roger-fletcher

Post on 21-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

PROGRAM DESIGN

Page 2: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Introduction

• The process of design involves “conceiving and planning out in the mind” and making a drawing , pattern or sketch of”.

• In software design there are three distinct type of activities:

» External Design.» Architectural design.» Detailed design.

Page 3: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Introduction

• External design of software involves conceiving ,planning out and specifying the external observable characteristics of a software product.

• These characteristics include user display and report format , external data source.

• Functional characteristics , performance requirements and high level process structure for the product.

• External design begins during the analysis phase and continues into design phase.(Analysis,design,implementation,testing, maintenance) .

Page 4: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Introduction

• Requirement definition is concerned with specifying the external , functional and performance requirements for a system.

• External design is concerned with refining those requirements and establishing the high level structural view of the system.

Page 5: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Introduction

• Internal design involves conceiving , planning out and specifying the internal structure and processing details of software product.

• The goals of internal design are to specify internal structure and processing detail , to record design decision and indicate why certain alternatives and trade off were chosen.

• The work product of internal design include a specification of architectural structure the details of algorithm and data structure and the test plan.

Page 6: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Introduction

• Architectural design is concerned with refining the conceptual view of the system.

• Identifying internal processing functions, decomposing high level functions into sub functions, defining internal data stream and data stores and establishing relationship.

• Actual interconnection among the functions and data structures and the packaging scheme for the system.

Page 7: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Abstraction• Abstraction is the intellectual tool that allow us to deal

with concepts apart from particular instance of those concept.

• During software design abstraction allow us to organize and channel our thought process by postponing structural consideration and detailed algorithmic consideration.

• Three widely used abstraction mechanism in software design are:

functional abstraction. data abstraction.control abstraction.

1. Abstraction.2. Information hiding.3. Structure.4. Modularity.5. Concurrency6. Verification

Page 8: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Functional abstraction involves the use of parameterized sub programs.

The ability to parameterized a sub program and to bind different parameter values on different invocations of the sub program is a powerful abstraction mechanism.

Functional abstraction can be generalized to collections of sub programs in which some routines are visible and some are hidden ,visible routines communicate with other groups and the hidden routine exist to support the visible ones

Page 9: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Data abstraction specifying a data type or a data type or a data object by specifying legal operation on object.

Abstract data types are abstract in the sense that representation details of the data items are hidden within the group that implements the abstract type.

Other groups that use the abstraction do not have access to the internal details of abstract object, object of abstract type are thus only known by the functions that can be performed on them.

Page 10: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Control abstraction is the third commonly used abstraction mechanism in software design.

Control abstraction is used to state a desired effect without stating the exact mechanism of control .

If statement and while statement in modern programming language are abstraction of machine code implementation.

Page 11: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Information hiding ,each module in the system hides the internal details of its processing activities and module communicate only through well defined interface.

Information hiding includes a data structure, its internal linkage and the implementation details of the procedure that manipulate it.(Data Abstraction)

Character codes , ordering of character sets, and other implementation details.

Machine dependent details.

Page 12: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Modularity, Module is a work assignment for an individual programmer.

Modular system consist of well defined ,manageable units and well defined interfaces among the units.

Modularity enhances design clarity which in turn eases implementation , debugging testing , documenting and maintenance of software product.

Page 13: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Modularity, each processing abstraction is well defined sub system that is potentially useful in other applications.

Each function in each abstraction has a single well defined purpose.

Each function manipulates no more than one data structure.

Function share global data selectively. It is easy to identify all routines that share a major data structure.

Function that manipulate the instances of abstract data types are encapsulated with the data structure being manipulated.

Page 14: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Concurrency, software system can be categorized as sequential or concurrent. In a sequential system only one portion of the system is active at given time, concurrent system have independent processes that can be activated simultaneously if multiple processes are available.

On a single processor concurrent processes can be interleaved in execution time. This permits implementation of time shared , multi programmed and real time systems.

Problem unique to concurrent system include deadlock, mutual exclusion and synchronization of processes.

Dead lock is an undesirable situation that occur when all processes in a computing system are waiting for other processes to complete some action so that each can proceed.

Mutual exclusion is necessary to ensure that multiple process do not attempt to update the same component of the shared processing state at the same time.

Synchronization is required so that concurrent processes operating at different execution speeds can communicate at the appropriate point in their execution history.

Page 15: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Fundamental Design Concept

Verification, Design is the bridge between customer requirements and an implementation that satisfies those requirements.

A design is verifiable if it can be demonstrated that the design will result in an implementation that satisfy the customer’s requirements . This is typically done in two steps:

Verification that the software requirerments definition satisfies the customer’s needs( verification of the requirements)

Verification that the design satisfies the requirement definition (verification of the design)

Page 16: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Modules and Modularization

Architectural design has the goal of producing well structured, modular software system.

Example of modules include function, procedure and subroutine.

software module to be a named entity having the following characteristics:

Modules contain instruction, processing logic and data structure .

Modules can be separately combined and stored in a library. Modules can be included in a program. Modules segment can be used by invoking a name or some

parameter. Modules can use other modules.

Page 17: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Modules and Modularization

Modularization allows the designer to decompose a system into functional units, to impose hierarchical ordering on function usage, to implement data abstraction and to develop independently useful subsystem.

Modularization can be used to isolate machine dependencies, to improve the performance of a software product , or to ease debugging, testing, integration and modification of the system.

Page 18: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Modules and Modularization

Coupling. The goal of software design is to minimize the complexity of

interconnection between module is minimized. The strength of coupling between two modules is influenced by

the complexity of the interface, the type of connection and the type of communication.

Modification of a common data block or control block may require modification of all routine that are coupled to that block.

Communication between modules involves passing of data, passing elements of control and modification of one modules code by another module.

Coupling is the measure of the interdependence of one module to another module.

Page 19: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Modules and Modularization

Coupling between modules can be ranked on a scale of strongest(least desirable) to weakest (most desirable) as follows:

1. Content Coupling- content coupling occurs when one module modifies the local data values or instruction in another module.

2. Common coupling- Modules are bound together by global data structures. Common coupling results when all routines in a program references a single common data block.

3. Control coupling- control coupling involves passing control flags between modules so that one module controls the sequence of processing steps in another module.

4. Stamp coupling- It is similar to common coupling . Except that global data item are shared selectively among routines that require the data. Stamp coupling is more desirable than common coupling.

5. Data coupling- Involves the use of parameter lists to pass data items between routines .The most desirable form of coupling between modules is a combination of stamp and data coupling.

Page 20: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Modules and Modularization

Cohesion:Cohesion of the module is measured in terms

of the strength of binding of elements within the module.

Cohesion of a module is measured in terms of strength association of the elements within the module.

Page 21: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Cohesion of element occurs on the scale of weakest(least desirable) to strongest (most desirable) as follows:

1. Coincidental Cohesion- It occurs when the elements in the module have no apparent relationships to one another.

2. Logical Cohesion- Implies some relationship among the elements of the module as for example in a module that performs all input and output operations or in a module that edits all data.

3. Temporal Cohesion- In this all elements are executed at one time and no parameter or logic are required to determine which element to execute.(Program initialization)

4. Communication Cohesion- It refers to the same set of input and out put data. In this element are executed at one time and also refers to the same data.

5. Sequential Cohesion- It occurs when the output of one element is the input for the next element.

6. Functional Cohesion-It is a strong and hence desirable type of binding of elements in module because all elements are related to the performance of a single function. Eg. “Compute square root”, “Obtain random number”,” Write record to file”.

7. Informational Cohesion- It occurs when the nodule contains a complex data structure and several routines to manipulate the data structure. Each routine in the module exhibits functional binding.

Page 22: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Modules and Modularization

In Summary the goal of modularizing a software system using the coupling cohesion criteria is to produce systems that have between the modules and

of elements within each module.

Stamp and Data Coupling functional or informational cohesion

Page 23: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Design Notation

Procedure TemplatesPROCEDURE NAME:PART OF :CALLED BY:PURPOSE:DESIGNER /DATE(s):

PARAMETER:(name,modes,attributes,purpose)INPUT ASSERTION :(precondition)OUTPUT ASSERTION:(post condition)GLOBAL:SIDE EFFECTS:

LOCAL DATA STRUCTURE:(name,attributes,purpose)EXCEPTION:(precondition, response)TIMING CONSTRAINTS:OTHER LIMITATIONS:

LEVEL 1

LEVEL 2

LEVEL 3

Page 24: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Design Notation

Procedure interface specification are effective notations for architectural design when used in combination with structures charts and data flow diagram.

Modification of global variable, reading or writing a file, opening or closing a file or calling a procedure that exhibits side effects.

Page 25: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Pseudocode

Peseudocode notation can be used in both the architectural and detailed design phases.

Like flow chart pseudocode can be used at any level of abstraction.

Using pseudocode, the designer describes system characteristics using short concise English language phrases.

Pseudocode can replace flow chart and reduce the amount of external documentation required to describe the system.

Peseudocode structured by key words such as if-Then-Else, While – Do and END.

Page 26: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Structured Flow Chart

Notations used in traditional flow chart are similar in structured flow chart but they differ from traditional flow chart.

Structures flow chart are restricted to compositions of certain basic forms. This makes the resulting flow chart the graphical equivalent of a structured pseudocode description.

Because structured flow chart are logically equivalent to pseudocode they have the same expressive power as pseudocode ; both can be used to express any conceivable algorithm.

Page 27: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Structured Flow Chart

Pseudocode

Statement 1

Statement 2

While p do s

Exit

S1

S2

P

F

T

S

END

Page 28: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Decision Table

Decision table can be used to specify complex decision logic in a high level software specification.

They are also useful for specifying algorithmic logic during detailed design.

Decision tables for recording complex decision logic .

Decision tables are widely used in data processing application and have an extensively developed literature.

Page 29: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Programming Language

Any notation for the description of algorithm and data structure may be termed as a programming language.

We define a programming language as a systematic notation by which we can describe some computational process to others.

Here computational process means the steps or instructions that computer can understand to solve a particular problem.

using the constructs (constructs means different types of statements provided by a languages such as loops, conditional statements, arithmetic statements etc.) provided by a particular language, we can tell to the computer how to solve a particular problem.

Page 30: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Need of studying programming language/Why to study programming language

The following are the reasons or benefits of studying language concepts:

To improve your ability to develop effective algorithms. Improved background for choosing appropriate

languages or to allow a better choice of programming language.

Increased ability to learn new languages. To increase your vocabulary of useful programming

constructs. To make it easier to design a new language. Overall advancement of Computing

Page 31: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Short History of Programming language

Programming language design and implementation method have evolved continuously since the earliest high level languages appeared in the 1950s.

Of the 12 languages described in some detail the first version of FORTRAN & LISP were designed during 1950s.

Ada ,c , Pascal, Prolog,and small talk date from the 1970s.

C++ , ML ,Perl, and post script date from 1980s. And JAVA date from 1990s

Page 32: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Development in Programming Methodologies

Numerically Based Language.

Business Language.

Artificial-intelligence language.

Systems Language.

Page 33: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Development in Programming Methodologies

Numerically Based Language.

Business Language.

Artificial-intelligence language.

Systems Language.

Page 34: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Evolution of Software Architecture

The external environment supporting the execution of a program is termed its operating or target environment. .

The environment in which a program is being coded, designed, tested and debugged are host environment, may be different from the operating environment in which the program ultimately used.

The computing industry has now entered its third major era in the development of computer programs.

Page 35: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Mainframe Era

Batch Environment: In this a program takes a set of data files as input, processes

the data and produces and produces a set of output data files. This operative environment is termed batch processing

because the input data are collected and processed in batches. Language such as FORTRAN, COBOL and PASCAL were

initially designed for batch processing environment.

Interactive Environment: In an interactive environment a program interacts directly

with a user at a display console during its execution , by alternately sending output to the display and receiving input from the keyboard or mouse.

Page 36: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Personal Computer Era

Personal Computer(1970 to 1980s)The 1970c could be called the era of mini computer.

These were progressively smaller and cheaper machine than mainframe era.

Embedded Environment:A computer system that is used to control part of larger

system such as an aircraft, a machine tool and automobile or even your toaster is termed as embedded computer system.

Failure of an embedded application can often be life threatening ,C and C++ are used extensively to meet some of the special requirement of embedded system.

Page 37: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Networking Era

Distributed Computing As machine became faster smaller and cheaper during 1980s they

started to populate the business environment. Companies would have central machines for handling corporate data

and each department would have local machine for providing support to that department.(client server model)

Internet In 1990 the emergence of distributed LAN. In 1970 DARPA started research project to link together mainframe

computer. Initially FTP and TELNET were the protocol which works in internet. At the same time third protocol SMTP developed basis for to days

email. In 1980s Berns Lee developed concept of HTML.

Page 38: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

StepwiseRefinement is a relatively old technique in SoftwareDesign that has been successfully used in a wide range  StructuredProgramming and ModularProgramming environments and languages. It is the procedural (step-by-step) form of SeparationOfConcerns

A systematic, iterative program design technique that unfortunately may lead to software that is hard to evolve

At each step, problem P decomposed into sequence of subproblems: P1; P2; …Pn a selection: if (cond) then P1 else P2 an iteration: while (cond) do_something

Stepwise refinement

Page 39: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Examplederivation of selection sort

Step 1let n be the length of the array a to be sorted;i := 1 ;while i < n loop

find the smallest of ai .. .an, and exchange it with the element at position i;i := i + 1;

end loop; 

Page 40: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Step 2let n be the length of the array a to be sorted;i := 1 ;while i < n loop

j := n;while j > i loop

if a(i) > a(j) theninterchange the elements at

positions j and i ;end if;j := j - 1;

end loop;i := i + 1;

end loop;

Page 41: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Step 3let n be the length of the array a to be sorted;i := 1 ;while i < n loop

j := n;while j > i loop

if a(i) > a(j) thenx := a(i); a(i) := a(j); a(j) := x;

end if;j := j - 1;

end loop;i := i + 1;

end loop;

The advantage of StepwiseRefinement is that it allows or IncrementalDevelopment but on a much finer level of granularity

Page 42: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Abstraction• At the highest level of abstraction – a solution is stated in broad

terms• At lower level of abstraction – a more detailed description of the

solution is provided.

Two types of abstraction:• Procedural abstraction: Sequence of instructions that have a

specific and limited function.Ex. Open a dooropen implies long sequence of activities (e.g. walk to the door, grasp

knob, turn knob and pull the door, etc).

• Data abstraction: collection of data that describes a data object. Ex. Open a door. – door is data object.• Data abstraction for door would encompass a set of attributes that

describe the door. (E.g. door type, swing direction, opening mechanism, etc.)

Page 43: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Characteristics are common to all design methods

• A mechanism for the translation of analysis model into a design representation,

• A notation for representing functional components and their interfaces.

• Heuristics for refinement and partitioning• Guidelines for quality assessment.

Page 44: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Design quality attributes

• Acronym FURPS – – Functionality– Usability– Reliability– Performance– Supportability

Page 45: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

• Functionality – is assessed by evaluating the feature set and capabilities of the program.– Functions that are delivered and security of the overall

system.• Usability – assessed by considering human factors, consistency &

documentation.• Reliability – evaluated by – measuring the frequency and severity of failure.– Accuracy of output results.– Ability to recover from failure and predictability of the

program.• Performance - measured by processing speed, response time,

resource consumption, efficiency.• Supportability – combines the ability to extend the program

(extensibility), adaptability and serviceability.

Page 46: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Integration testing

• Integration testing is a systematic technique for constructing the program structure while at the same time conducting tests to uncover errors associated with interfacing.

• The objective is to take unit tested components and build a program structure that has been dictated by design.

• The program is constructed and tested in small increments, where errors are easier to isolate and correct;

Page 47: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Top-down Integration

• Top-down integration testing is an incremental approach to construction of program structure.

• Modules subordinate to the main control module are incorporated into the structure in either a depth-first or breadth-first manner.

• Depth-first integration would integrate all components on a major control path of the structure.

• Selection of a major path is somewhat arbitrary and depends on application-specific characteristics.

• For example, selecting the left hand path, – Components M1, M2 , M5 would be integrated first. – Next, M8 or M6 would be integrated– The central and right hand control paths are built.

Page 48: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Top down integration

Page 49: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Top-down Integration process five steps:

1. The main control module is used as a test driver and stubs are substituted for all components directly subordinate to the main control module.

2. Depending on the integration approach selected (i.e., depth or breadth first), subordinate stubs are replaced one at a time with actual components.

3. Tests are conducted as each component is integrated

4. On completion of each set of tests, another stub is replaced with the real component.

5. Regression testing may be conducted to ensure that new errors have not been introduced.

The process continues from step 2 until the entire program structure is built.

Page 50: Introduction The process of design involves “conceiving and planning out in the mind” and making a drawing, pattern or sketch of”. In software design

Recommender system

Search

Product 1 Product 2

Product 3 Product 4