You are on page 1of 31

C++ Plus Data Structures

Nell Dale

Chapter 1
Software Engineering Principles

1
Software Design Process

2
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 3


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.
4
Toolboxes:

● Hardware.
● Software
● Ideaware (focus of the course!): the
shared body of knowledge that
programmers have collected over
time, including algorithms, data
structures, programming
methodologies, tools…
5
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.

6
Goals of Quality Software
● It works.
● It can be read and understood.
● It can be modified.
● It is reusable.

● It is completed on time and within budget.

7
Specification:
Understanding the Problem

Detailed Program Specification

● Tellswhat the program must


do, but not how it does it.

● Iswritten documentation about


the program.
8
Writing Detailed Specifications

Detailed Program Specification


Includes:
● Inputs

● Outputs
● Processing requirements
● Assumptions
9
Program Design

Software design use some ideaware tools such


as abstraction , information hiding , stepwise
refinement and visual tools.

10
Abstraction

● A model of a complex system that


includes only the details essential to
the perspective of the viewer of the
system. (consider the essential
characteristics of the system only;
ignore minor or relative details )

11
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.

12
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
13
Functional Design Modules
Main

Prepare Find Print


File for Get Data Print Data Weighted Weighted
Reading Average Average

Print Heading

14
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

15
More about OOD
● Languages supporting OOD include: C++, Java,
Smalltalk, Eiffel, and Object-Pascal, C, …

● 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.

16
Verification of Software
Correctness

• Testing
• Debugging
• Program verification

17
Program Verification

● Program Verification is the process of


determining the degree to which a
software product fulfills its
specifications.
SPECIFICATIONS
Inputs
Outputs
Processing
Requirements
PROGRAM
Assumptions

18
Verification vs. Validation

Program verification asks,


“Are we doing the job right?”

Program validation asks,


“Are we doing the right job?”

19
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

...
20
Origin of Bugs

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. 21
Design for Correctness

22
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.

23
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

24
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 . . .
25
Design Review Activities
● Deskchecking: tracing an execution of a
design or program on paper (checklist
Fig1.5, pg32).
● 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 an the others point out
errors.
26
Program Testing
● Unit Testing: testing a module or
function by itself
● Data Coverage: testing all possible
input values (Black Box Testing)
● Code Coverage: testing program paths
(Clear/White Box Testing)
● Statement coverage
● Integration Testing
27
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.

28
Integration Testing

● Is performed to integrate program modules


that have already been independently unit
tested.
Main

Prepare Print Data Find Print


Get Data
File for Weighted Weighted
Reading Average Average

Print Heading
29
Practical Considerations

30
Life-Cycle Verification
Activities:

● Analysis
● Design
● Code
● Test
● Delivery
● Maintenance

It's From
Bekham To All 31

You might also like