1 software engineering principles n.
Skip this Video
Download Presentation
1 Software Engineering Principles

Loading in 2 Seconds...

play fullscreen
1 / 66

1 Software Engineering Principles - PowerPoint PPT Presentation

  • Uploaded on

1 Software Engineering Principles. Programming Life Cycle Activities. 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

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about '1 Software Engineering Principles' - morrie

Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
programming life cycle activities
Programming Life Cycle Activities
  • 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
software engineering
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.
an algorithm is
An Algorithm Is . . .
  • A logical sequence of discrete steps ( a step by step description) that describes a complete solution to a given problem computable in a finite amount of time.
  • Hardware – computers and their peripheral devices
  • Software – OS, text editors, debugging programs, test data generators etc.
  • Ideaware – knowledge collected over time: algorithms to solve common problems, as well as data structures; programming methodologies: top-down and object-oriented design; tools for measuring, evaluating, and proving the correctness of our programs.
goals of quality software
Goals of Quality Software
  • 1. It works. It should meet the user’s requirements.
  • 2. It can be modified. Software changes can happen in all phases of its life cycle.
    • What makes a program easy to modify? It should be readable and understable.
  • 3. It is reusable.
    • A well-designed, clearly written, well-documented program. It’s difficult to remember all the details after some time passed. So it can be quickly determines whether it can be reused for a new project.
    • Try to generalize routines.
  • 4. It is completed on time and within budget. Failure to meet deadlines is expensive.
1 program specification translates the user s requirements
1. Program Specification – translates the user’s requirements
  • Tells what the program must do, but not how it does it.
  • It is written documentation about the program.
1 software specification a detailed description includes
1. Software Specification – a detailed description - includes
  • Inputs (do you need to check for errors in the input)
  • Outputs
  • Processing requirements and error handling
  • Assumptions about the problem
1 software specification a detailed description
1. Software Specification – a detailed description
  • Can include User/operational/scenario
    • A scenario is a sequence of events for one execution of the program p.8 see an ATM example
    • Scenarios allow us to get a feel for the behavior expected from the system. A single scenario cannot show all possible behaviors.
  • Can serve as an important piece written documentation
  • Clarifies the problem to be solved
fundamental principles of software engineering used in the program design
Fundamental Principles of Software Engineeringused in the Program Design
  • 1. Abstraction
    • A model of a complex system that includes only the details essential to the perspective of the viewer of the system.

e.g. although the earth in oblate ellipsoid, globes (models of the earth) are spheres

e.g. the car user versus the automotive brake engineer

Abstraction is our most powerful tool for dealing with this complexity.

fundamental principles of software engineering
Fundamental Principles of Software Engineering
  • 2. 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 dependingon low-level design details that may be changed. Lower levels of the program design are hidden from the higher levels. Changes in lower levels shouldn’t result in changes in higher levels.

The programmers seesonly the details that are relevant at a particular level of the design (e.g. you can stop a car without knowing whether it has disk or drum brakes).

You don’t want to require a complete understanding of the complicated details for the design of higher-level routines

(complexity decrease).

fundamental principles of software engineering1
Fundamental Principles of Software Engineering
  • 3. Stepwise Refinement
    • A problem is approached in stages. Similar steps are followed during each stage, with the only difference being the level of detail involved. Some strategies:
      • Top-down – the problem is first broken into several large parts. Each of these parts is, in turn, divided into sections, the sections are subdived, and so on.
      • Bottom-up – the details comes first. After the detailed components are identified and designed, they are brought together into increasingly higher level components.
      • Functional decomposition – is top-down stepwise refinement with an emphasis on functions.
      • Round-trip gestalt design – is top-down stepwise refinement to object-oriented design; identify objects and their relationships, do many round of design.
  • Visual Aids – CRC (Class, Responsibility and Collaboration ) Cards
    • tool for refining an object-oriented design.
    • identify and assign
      • responsibilities (verbs implemented by functions and
      • collaborations (other classes or objects that are used in fulfilling the responsibility.
two approaches to building manageable modules

Identifies various

objects composed of

data and operations,

that can be used

together to solve

the problem.

Divides theproblem

intomore easily handled

subtasks,until the

functional modules

(subproblems) can

be coded.

Two Approaches to Building Manageable Modules


= top-down design


FOCUS ON: tasks (processes)FOCUS ON: data objects

In both design methodologies, abstraction and information hiding are of primary importance.

functional design







Functional Design


Get Data


File for


Print Data

Print Heading

functional design1
Functional Design
  • In functional decomposition
    • the main module of the design becomes the main program and subsections develop into functions
    • information hiding is accomplished primarily through deferring the details of algorithms
  • Mix Strategy – combination of top-down design and OO design
    • When decomposition reaches the level of operation on data, you can implement the data and operations as objects
object oriented design
Object-Oriented Design

A 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

Private data








more about ood
More about OOD
  • Languages supporting OOD include: C++, Java, Smalltalk, Eiffel, and Object-Pascal.
  • Aclass 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
    • coutis an object of a class ostream.
    • Header files iostream and fstream contain definitions of stream classes.
  • C++ types are templates for variables; classes are templates for objects
procedural vs object oriented code
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.”

Grady Booch, “What is and Isn’t Object Oriented Design,” 1989.

Functional decomposition produces a hierarchy of tasks

Object-oriented design produces a hierarchy of cooperating objects

program testing




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


. . .

for each test case
For Each Test Case:
  • Determine inputs.
  • Determine the expected behavior of the program.
  • Run the program and observe the resulting behavior.
  • Compare the expected behavior and the actual behavior.

Program Verification

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








program validation
Program Validation
  • The process of determining the degree to which software fulfills its intendedpurpose.
verification vs validation
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.

types of errors
Types of Errors
  • Specification
  • Design
  • Coding
  • Input
basic principle
  • A basic principle about software costs:
    • The earlier in the development cycle a problem is detected, the cheaper it is to fix.
expert knowledge
  • It is worthwhile to develop an expert knowledge of both
    • The control and data structures
    • The syntax of the language
keyboard and screen i o


(of type istream)


(of type ostream)

Keyboard and Screen I/O

#include <iostream>

using namespace std;

output data

input data





  • In slides that follow, assume the statement:

using namespace std;

  • We explain namespace in Chapter 2
iostream is header file
<iostream> is header file
  • for a library that defines 3 objects
  • an istream object named cin (keyboard)
  • an ostream object named cout (screen)
  • an ostream object named cerr(screen)
insertion operator
Insertion Operator ( << )
  • The insertion operator << takes 2 operands.

cout << “Enter part number followed by return : “ ;

  • The left operand is a stream expression, such as cout.
  • The right operand is an expression describing what to insert into the output stream.It may be of simple type, or a string, or a manipulator (like endl).
extraction operator
Extraction Operator ( >> )
  • Variable cin is predefined to denote an input stream from the standard input device( the keyboard ).

cin >> partNumber ;

  • The extraction operator >> called “get from” takes 2 operands. The left operand is a stream expression, such as cin. The right operand is a variable of simple type.
  • Operator >> attempts to extract the next item from the input stream and store its value in the right operand variable.
extraction operator1
Extraction Operator >>

“skips”(reads but does not store anywhere)

leading whitespace characters

(blank, tab, line feed, form feed, carriage return)

before extracting the input value from the stream (keyboard or file).

To avoid skipping, use function get to read the next character in the input stream.


#include <iostream>

using namespace std;

int main( )


int partNumber;

float unitPrice;

cout << “Enter part number followed by return : “

<< endl ; // prompt

cin >> partNumber ;

cout << “Enter unit price followed by return : “

<< endl ;

cin >> unitPrice ;

cout << “Part # “ << partNumber // echo

<< “at Unit Cost: $ “ << unitPrice << endl ;

return 0;



disk files for i o

input data

output data

Disk files for I/O

#include <fstream>

disk file


disk file




your variable

(of type ifstream)

your variable

(of type ofstream)

for file i o
For File I/O
  • 1. use

#include <fstream>

  • 2. choose valid variable identifiers for your files and declare them

ifstream myInfile; // declarations

ofstream myOutfile;

  • 3. open the files and associate them with disk names

myInfile.open(“A:\\myIn.dat”);// open files


  • 4. use your variable identifiers with >> and <<
  • 5. close the files

myInfile.close( ); // close files

myOutfile.close( );

statements for using file i o
Statements for using file I/O

#include <fstream>

using namespace std;

ifstream myInfile; // declarations

ofstream myOutfile;

myInfile.open(“A:\\myIn.dat”);// open files


myInfile.close( ); // close files

myOutfile.close( );

what does opening a file do
What does opening a file do?
  • associates the C++ identifier for your file with the physical (disk) name for the file
  • if the input file does not exist on disk, open is not successful
  • if the output file does not exist on disk, a new file with that name is created
  • if the output file already exists, it is erased
  • places a file reading marker at the very beginning of the file, pointing to the first character in it
#include <fstream>

using namespace std;

int main( )


int partNumber;

float unitPrice;

ifstream inFile; // declare file variables

ofstream outFile;

inFile.open(“input.dat”); //open files


inFile >> partNumber ;

inFile >> unitPrice ;

outFile << “Part # “ << partNumber // echo

<< “at Unit Cost: $ “ << unitPrice << endl ;

return 0;



stream failure
Stream Failure
  • When a stream enters the fail state, further I/O operations using that stream are ignored. But the computer does not automatically halt the program or give any error message. !!!
  • Possible reasons for entering fail state include:
    • invalid input data (often the wrong type),
    • trying to input a value when the stream is at the end of the file,
    • opening an input file that doesn’t exist,
    • opening an output file on a diskette that is already full or is write-protected.
#include <fstream>

#include <iostream>

using namespace std;

int main( )


ifstream inFile;

inFile.open(“input.dat”); // try to open file

if ( !inFile ) //test the state of the stream


cout << “File input.dat could not be opened.”;

return 1;


. . .

return 0; //the ISO Standard – a successful completion code



various types of errors
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.
  • Robustness is the ability of a program to recover following an error; the ability of a program to continue to operate within its environment.
  • It is generally unwise to make too many assumptions about the correctness of input
    • check explicitly for the correct type and bounds of such input
    • Decide how an error should be handle
      • request new input,
      • print a message, or
      • go on to the next data
    • Some run-time errors
      • Swapped 2 parameters of the same type on a function call,
      • Forgotten to designate a function’s output data as a reference parameter
an assertion
An Assertion
  • Is a logical proposition that is either true or false (not necessarily in C++ code).


studentCount is greater than 0

sum is assigned && count > 0

response has value ‘y’ or ‘n’

partNumber == 5467

We use preconditions and postconditions at the module level or function level because it help us to design programs in a truly modular fashion.

preconditions and postconditions
Preconditions and Postconditions
  • The preconditionis an assertion describing what a function requires to be truebefore beginning execution.
  • The postconditiondescribes what must be true at the moment the function finishes execution.
  • The calleris responsible for ensuring the precondition, and the function code must ensure the postcondition.


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.

{ using namespace std;

int length;

ItemType item;


length = list.LengthIs();

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







another example
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-negative.

// Post: root1 and root2 are assigned

// root1 and root2 are roots of quadratic with coefficients a, b, c


using namespace std;

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

root1 = (-b + sqrt(temp) ) / ( 2.0 * a ); root2 = (-b - sqrt(temp) ) / ( 2.0 * a ); return;


design review
Design Review
  • 1. Deskchecking is tracing an execution of a design or program on paper (see p. 32)
  • A checklist of typical errors:
    • Verify essential data (variables, input values, parameters of subprograms)
    • Loops that don’t terminate,
    • Variables that are used before they are initialized,
    • Incorrect order of parameters on function calls
design review1
Design Review
  • 2. 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.
  • Successful completion of the design inspection means that testing of the program can begin
design review2
Design Review

3. Inspection. A verification method in which one member of a team reads the program or design line by line and others point out errors.


Testing Selection Control Structures

  • to test a program with branches, use enough data sets so that every branch is executed at least once
  • this is called minimum complete coverage

Unit testing. Testing a class or function by itself

testing often combines two approaches
Testing Often Combines Two Approaches



Data Coverage

Data values at

the boundaries, and

possibly middle values,

example of each category of inputs can be tested.

Code Coverage

Allows us to see the

program code while

designing the tests.

Ensure that each statement in the program is executed at least once.

We could say that 75% of the branches of a program have been executed or 50% of the path have been tested (metric based testing).

tasks within each test case
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.
how to test a program
How to Test a Program
  • design and implement a test plan
  • a test plan is a document that specifies the test cases planned for a program or module, which includes
    • purposes
    • conditions of the test cases
    • inputs,
    • and the expected output
  • implement the test plan by verifying that the program outputs the predicted results
test plans
Test Plans
  • For program testing to be effective, it must be planned.
  • Start planning for testing before writing a single line of code.
// Generic Test Driverfor the set of commands/operations p.47-48 implementation

Declare an instance of the class being tested

Prompt for, read the input file name, and open the file

Prompt for, read the output file name, and open the file

Prompt for and read the label (= test name) for the output file

Write the label on the output file

Read the next command from the input file

Set numCommands to 0

While the command read is not ‘quit’

Execute the command by invoking the member function of the same name

Print the results to the output file

Increment numCommands by 1

Print “Command number” numComands “completed” to the screen

Read the next command from the input file

Close the input and output files.

Print “Testing completed” to the screen

// Test driver with instructions for filling in specific

// information

#include <iostream>

#include <fstream>

#include <string>

// #include file containing class to be tested

int main()


using namespace std;

ifstream inFile; // file containing operations

ofstream outFile; // file containing output

string inFileName; // input file external name

string outFileName; // output file external name

string outputLabel;

string command; // operation to be executed

int numCommands;

// Declare a variable of the type being tested

// Prompt for file names, read file names, and prepare files

cout << "Enter name of input file; press return." << endl;

cin >> inFileName;


cout << "Enter name of output file; press return." << endl;

cin >> outFileName;


cout << "Enter name of test run; press return." << endl;

cin >> outputLabel;

outFile << outputLabel << endl;

inFile >> command;

numCommands = 0;

while (command != "Quit")


// The following should be specific to structure being tested

// Execute the command by invoking the member function of the

// same name

// Print the results to the output file


cout << "Command number " << numCommands << " completed."

<< endl:

inFile >> command;


cout << "Testing completed." << endl;



return 0;


phase result testing technique

Problem solving Algorithm Algorithm deskchecking,


Implementation Coded program Code walk-through,


Compilation Object program Compiler messages

Execution Output Implement test plan

integration testing
Integration Testing
  • Is performed to integrate program modules that have already been independently unit tested.


Get Data





File for





Print Data

Print Heading

integration testing approaches
Integration Testing Approaches


Assumption: the lower levels

work correctly


Ensures individual modules

work together correctly,

beginning with the

lowest level.

Ensures correct overall

design logic and the

interfaces between modules

are correct.

USES: placeholder USES: a test driver to call

module “stubs” to test the functions being tested.

the order of calls.

A stub may consist a single/Effective in a group programming

group trace/debug output statements environment where each programmer has

tested already own modules/functions.

  • The earlier in the software development cycle program errors are detected, the easier and less costly in time, effort, and money the are to remove.