0% found this document useful (0 votes)
2 views45 pages

Software Engineering Principles Overview

The document outlines key software engineering principles, including the software life cycle, program design, and verification processes. It emphasizes the importance of structured approaches such as abstraction, information hiding, and stepwise refinement in software development. Additionally, it discusses testing methodologies and error management to ensure software quality and correctness.

Uploaded by

khloud farouk
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views45 pages

Software Engineering Principles Overview

The document outlines key software engineering principles, including the software life cycle, program design, and verification processes. It emphasizes the importance of structured approaches such as abstraction, information hiding, and stepwise refinement in software development. Additionally, it discusses testing methodologies and error management to ensure software quality and correctness.

Uploaded by

khloud farouk
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

Software
Engineering
Principles

1.1 The Software Process


1.2 Program Design
1.3 Verification of Software
Correctness
1.1 The Software Life Cycle

• Problem analysis
• Requirements elicitation
• Software specification
• High- and low-level design
• Implementation
• Testing and Verification
• Delivery
• Operation
• Maintenance
2
1.1 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.
3
1.1 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.

4
1.1 Programmer ToolBoxes

• Hardware—the computers and their


peripheral devices
• Software—operating systems, editors,
compilers, interpreters, debugging
systems, test-data generators, and so
on
• Ideaware – shared body of knowledge
Algorithms and Data Structures
Abstraction, information hiding,
Stepwise refinement, visual tool
5
1.1 Goals of Quality Software

• It works.—Complete, Correct, Efficient


• It can be modified without excessive
time and effort.—Readable, Understandable
• It is reusable.
• It is completed on time and within
budget.

6
1.1 Detailed Program Specification

• Tells what the program


must do, but not how it
does it.
• Is written documentation
about the program.
• Processing requirements
• Sample inputs with expected outputs
• Assumptions

7
1.2 Abstraction

• A model of a complex system that


includes only the details essential to the
perspective of the viewer of the system.
• Programs are abstractions.

Ideaware Tools for Software Design


• Abstraction
• Information hiding
• Stepwise refinement
• Visual tools

8
1.2 Abstraction (cont.)

9
1.2 Information Hiding

• The practice of hiding the details of a


module with the goal of controlling
access to the details from the rest of the
system.
• A programmer can concentrate on one
module at a time.
• Each module should have a single
purpose or identity.

10
1.2 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
variations:
• Top-down
• Bottom-up
• Functional decomposition
• Object-oriented design

11
1.2 Visual Aids – CRC Cards

12
Procedural
1.2 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.

13
1.2
Two Approaches to
Building Manageable Modules

FUNCTIONAL OBJECT-ORIENTED
DECOMPOSITION DESIGN

Divides the problem Identifies various


into more easily handled objects composed of
subtasks, until the data and operations,
functional modules that can be used
(subproblems) can together to solve
be coded. the problem.

FOCUS ON: processes FOCUS ON: data objects

14
1.2 Functional Design Modules

Main

Prepare Find Print


File for Get Data Print Data Weighted Weighted
Reading Average Average

Print Heading

15
1.2 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.
cin cout

>> <<

get Private data setf Private data


. .
. .
. .

ignore

16
1.3

17
1.3 Verification vs. Validation

Program validation
The process of determining the degree to which
software fulfills its intended purpose

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.

18
1.3 Types of Errors

• Specification
• Design
• Coding – Compile-Time Error
• Input – Run-Time Error

19
1.3
Cost of a Specification Error
Based on When It Is Discovered

20
1.3 Controlling Errors

Robustness The ability of a program to recover


following an error; the ability of a program to
continue to operate within its environment

Preconditions Assumptions that must be true


on entry into an operation or function for the
postconditions to be guaranteed.

Postconditions Statements that describe what


results are to be expected at the exit of an
operation or function, assuming that the
preconditions are true.

21
1.3 Design Review Activities

Deskchecking Tracing an execution of a design


or program on paper

Walk-through A verification method in which a


team performs a manual simulation of the
program or design

Inspection A verification method in which one


member of a team reads the program or
design line by line and others point out errors

22
1.3 Program Testing

Debugging: The process of removing known errors

23
1.3 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.

24
1.3 Types of Testing

Unit testing Testing a class or function by


itself
Black-box testing Testing a program or
function based on the possible input values,
treating the code as a “black box”
Clear (white) box testing Testing a program
or function based on covering all of the
branches or paths of the code

25
1.3 Integration Testing

• Is performed to integrate program modules


that have already been independently unit
tested.
Main

Prepare Find Print


Get Data Print Data
File for Weighted Weighted
Reading Average Average

Print Heading

26
1.3 Integration Testing Approaches

TOP-DOWN BOTTOM-UP

Ensures correct overall Ensures individual modules


design logic. work together correctly,
beginning with the
lowest level.
USES: placeholder USES: a test driver to call
module “stubs” to test the functions being tested.
the order of calls.

Test driver: A program that sets up the testing environment


by declaring and assigning initial values to variables, then
calls the subprogram to be tested.
27
1.3 Test Plans

• Document showing the test cases


planned for a program or module, their
purposes, inputs, expected outputs, and
criteria for success
• For program testing to be effective, it
must be planned.
• Start planning for testing before writing a
single line of code.

28
1.3 Testing C++ Structures

29
1.3
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 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
30
1.3 Life-Cycle Verification Activities

31
1.3
Keyboard and Screen I/O

#include <iostream>
using namespace std;
input data output data

executing
Keyboard program Screen

cin cout

(of type istream) (of type ostream)

32
1.3 namespace

• In slides that follow, assume the


statement:
using namespace std;

• We explain namespace in Chapter 2

33
1.3 <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)

34
1.3 Insertion Operator ( << )

• The insertion operator << takes 2


operands.

• 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).
35
1.3 Extraction Operator ( >> )

• Variable cin is predefined to denote an input


stream from the standard input device ( the
keyboard ).

• 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.
36
1.3 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.
[Link](inputChar);

37
1.3

#include <iostream>
int main( )
{ // USES KEYBOARD AND SCREEN I/O
using namespace std;
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;
}
38
1.3 Disk files for I/O

#include <fstream>
input data output data

disk file executing disk file


“A:\[Link]” program “A:\[Link]”

your variable your variable

(of type ifstream) (of type ofstream)


39
1.3 For File I/O

• use #include <fstream>


• choose valid variable identifiers for your files and
declare them

• open the files and associate them with disk names

• use your variable identifiers with >> and <<

• close the files


40
1.3 Statements for using file I/O

#include <fstream>
using namespace std;
ifstream myInfile; // declarations
ofstream myOutfile;

[Link](“A:\\[Link]”); // open files


[Link](“A:\\[Link]”);

[Link]( ); // close files


[Link]( );

41
1.3 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

42
1.3
#include <fstream>
int main( )
{ // USES FILE I/O
using namespace std;
int partNumber;
float unitPrice;
ifstream inFile; // declare file variables
ofstream outFile;

[Link](“[Link]”); //open files


[Link](“[Link]”);

inFile >> partNumber ;


inFile >> unitPrice ;
outFile << “Part # “ << partNumber // echo
<< “at Unit Cost: $ “ << unitPrice << endl ;
return 0;
}
43
1.3 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),
• opening an input file that doesn’t exist,
• opening an output file on a diskette that is
already full or is write-protected.

44
1.3

#include <fstream>
#include <iostream>
using namespace std;
int main( )
{ // CHECKS FOR STREAM FAIL STATE

ifstream inFile;
[Link](“[Link]”); // try to open file
if ( !inFile )
{
cout << “File [Link] could not be opened.”;
return 1;
}
. . .
return 0;
} 45

You might also like