Programming Life Cycle

26
Programming Life Cycle Problem analysis understand the problem Requirements definition specify what program will do High- and low-level design how it meets requirements Implementation of design code it Testing and verification detect errors, show correct Delivery turn over to customer Operation use the program Maintenance change the program

description

Programming Life Cycle. Problem analysis understand the problem Requirements definition specify what program will do High- and low-level design how it meets requirements Implementation of design code it Testing and verification detect errors, show correct Delivery turn over to customer - PowerPoint PPT Presentation

Transcript of Programming Life Cycle

Page 1: Programming Life Cycle

Programming Life Cycle• Problem analysis understand the problem

• Requirements definition specify what program will do

• High- and low-level design how it meets requirements

• Implementation of design code it

• Testing and verification detect errors, show correct

• Delivery turn over to customer

• Operation use the program

• Maintenance change the program

Page 2: Programming Life Cycle

Software Engineering

• A disciplined approach to the design, production, and maintenance of computer programs

• that are developed on time and within cost estimates,

• using tools that help to manage the size and complexity of the resulting software products.

Page 3: Programming Life Cycle

An Algorithm Is . . .

• A logical sequence of discrete steps that describes a complete solution to a given problem computable in a finite amount of time.

Page 4: Programming Life Cycle

Goals of Quality Software

• It works.

• It can be read and understood.

• It can be modified.

• It is completed on time and within budget.

Page 5: Programming Life Cycle

Detailed Program Specification

• Tells what the program must do, but not how it does it.

• Is written documentation about the program.

Page 6: Programming Life Cycle

Specification Includes

• Inputs

• Outputs

• Processing requirements

• Assumptions

Page 7: Programming Life Cycle

Abstraction

• A model of a complex system that includes only the details essential to the perspective of the viewer of the system.

Page 8: Programming Life Cycle

Information Hiding

• Hiding the details of a function or data structure with the goal of controlling access to the details of a module or structure.

PURPOSE: To prevent high-level designs from depending on low-level design details that may be changed.

Page 9: Programming Life Cycle

Two Design Approaches

Divides the problem into more easily handled subtasks, until the functional modules (subproblems) can be coded.

Identifies various objects composed of data and operations, that can be used together to solve the problem.

FUNCTIONALDECOMPOSITION

OBJECT-ORIENTED DESIGN

FOCUS ON: processes FOCUS ON: data objects

Page 10: Programming Life Cycle

FindWeighted Average

PrintWeighted Average

Functional Design Modules

Main

Print Data

Print Heading

Get DataPrepare File for Reading

Page 11: Programming Life Cycle

Object-Oriented DesignA technique for developing a program in which

the solution is expressed in terms of objects -- self- contained entities composed of data and operations on that data.

Private data

<<

setf...

Private data

>>

get...

ignore

cin cout

Page 12: Programming Life Cycle

More about OOD

Languages supporting OOD include: C++, Java, Smalltalk, Eiffel, and Object-Pascal.

A class is a programmer-defined data type and objects are variables of that type.

In C++, cin is an object of a data type (class) named istream, and cout is an object of a class ostream. Header files iostream.h and fstream.h contain definitions of stream classes.

Page 13: Programming Life Cycle

Procedural vs. Object-Oriented Code

“Read the specification of the software you want to build. Underline the verbs if you are after procedural code, the nouns if you aim for an object-oriented program.”

Brady Gooch, “What is and Isn’t Object Oriented Design,” 1989.

Page 14: Programming Life Cycle

• Program Verification is the process of determining the degree to which a software product fulfills its specifications.

Program Verification

PROGRAM

SPECIFICATIONS

Inputs

Outputs

Processing Requirements

Assumptions

Page 15: Programming Life Cycle

Verification vs. Validation

Program verification asks,

“Are we doing the job right?”

Program validation asks,

“Are we doing the right job?”

B. W. Boehm, Software Engineering Economics, 1981.

Page 16: Programming Life Cycle

Program Testing

• Testing is the process of executing a program with various data sets designed to discover errors.

DATA SET 1

DATA SET 2

DATA SET 3

DATA SET 4

. . .

Page 17: Programming Life Cycle

Various Types of Errors

• Design errors occur when specifications are wrong

• Compile errors occur when syntax is wrong

• Run-time errors result from incorrect assumptions, incomplete understanding of the programming language, or unanticipated user errors.

Page 18: Programming Life Cycle

Robustness

• Robustness is the ability of a program to recover following an error; the ability of a program to continue to operate within its environment.

Page 19: Programming Life Cycle

An Assertion• Is a logical proposition that is either true or false

(not necessarily in C++ code).

EXAMPLES

studentCount is greater than 0

sum is assigned && count > 0

response has value ‘y’ or ‘n’

partNumber == 5467

Page 20: Programming Life Cycle

Preconditions and Postconditions

• The precondition is an assertion describing what a function requires to be true before beginning execution.

• The postcondition describes what must be true at the moment the function finishes execution.

• The caller is responsible for ensuring the precondition, and the function code must ensure the postcondition.

FOR EXAMPLE . . .

Page 21: Programming Life Cycle

void PrintList ( ofstream& dataFile, UnsortedType list)

// Pre: list has been initialized.

// dataFile is open for writing.

// Post: Each component in list has been written to dataFile.

// dataFile is still open.

{ int length;

ItemType item;

list.ResetList();

length = list.LengthIs();

for (int counter = 1; counter <= length; counter++)

{

list.GetNextItem(item);

item.Print(dataFile);

}

}

35

Page 22: Programming Life Cycle

Another Example

void GetRoots (float a, float b, float c,

float& Root1, float& Root2 )

// Pre: a, b, and c are assigned.

// a is non-zero, b*b - 4*a*c is non-zero.

// Post: Root1 and Root2 are assigned

// Root1 and Root2 are roots of quadratic with coefficients a, b, c

{ float temp;

temp = b * b - 4.0 * a * c;

Root1 = (-b + sqrt(temp) ) / ( 2.0 * a );

Root2 = (-b - sqrt(temp) ) / ( 2.0 * a );

return;

}

Page 23: Programming Life Cycle

A Walk-Through

• Is a verification method using a team to perform a manual simulation of the program or design, using sample test inputs, and keeping track of the program’s data by hand.

• Its purpose is to stimulate discussion about the programmer’s design or implementation .

Page 24: Programming Life Cycle

Tasks within each test case:

• determine inputs that demonstrate the goal.

• determine the expected behavior for the input.

• run the program and observe results.

• compare expected behavior and actual behavior. If they differ, we begin debugging.

Page 25: Programming Life Cycle

Integration Testing

• Is performed to integrate program modules that have already been independently unit tested.

FindWeighted Average

PrintWeighted Average

Main

Print Data

Print Heading

Get DataPrepare File for Reading

Page 26: Programming Life Cycle

Integration Testing Approaches

Designed to ensurecorrect overall design logic.(the big picture)

Designed to ensure individual modules work together correctly, beginning with the lowest levels first. (the details)

TOP-DOWN BOTTOM-UP

USES: placeholder modules USES: a test driver to callcalled “stubs” to test the the functions being tested.order of calls.