32
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore County - Essex Campus

C++ Plus Data Structures

Embed Size (px)

DESCRIPTION

C++ Plus Data Structures. Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore County - Essex Campus. Software Design Process. Programming Life Cycle Activities. Problem analysis understand the problem - PowerPoint PPT Presentation

Citation preview

Page 1: C++ Plus Data Structures

1

C++ Plus Data Structures

Nell Dale

Chapter 1

Software Engineering Principles

Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore County - Essex Campus

Page 2: C++ Plus Data Structures

2

Software Design Process

Page 3: C++ Plus Data Structures

3

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

Page 4: C++ Plus Data Structures

4

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 5: C++ Plus Data Structures

5

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…

Page 6: C++ Plus Data Structures

6

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 7: C++ Plus Data Structures

7

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 8: C++ Plus Data Structures

8

Specification: Understanding the Problem

Detailed Program Specification

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

Is written documentation about the program.

Page 9: C++ Plus Data Structures

9

Writing Detailed Specifications

Detailed Program Specification Includes: Inputs

Outputs

Processing requirements

Assumptions

Page 10: C++ Plus Data Structures

10

Program Design

Page 11: C++ Plus Data Structures

11

Abstraction

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

Page 12: C++ Plus Data Structures

12

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 13: C++ Plus Data Structures

13

Two Approaches to Building Manageable

Modules

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 14: C++ Plus Data Structures

14

FindWeighted Average

PrintWeighted Average

Functional Design Modules

Main

Print Data

Print Heading

Get DataPrepare File for Reading

Page 15: C++ Plus Data Structures

15

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 16: C++ Plus Data Structures

16

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.

Page 17: C++ Plus Data Structures

17

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 18: C++ Plus Data Structures

18

Verification of Software Correctness

• Testing• Debugging• Program verification

Page 19: C++ Plus Data Structures

19

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 20: C++ Plus Data Structures

20

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 21: C++ Plus Data Structures

21

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.

Page 22: C++ Plus Data Structures

22

Design for Correctness

Page 23: C++ Plus Data Structures

23

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 24: C++ Plus Data Structures

24

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 25: C++ Plus Data Structures

25

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 26: C++ Plus Data Structures

26

Design Review Activities

Deskchecking: tracing an execution of a design or program on paper (checklist Fig1.4, pg31).

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.

Page 27: C++ Plus Data Structures

27

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)

Test Plans Planning for Debugging Integration Testing

Page 28: C++ Plus Data Structures

28

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 29: C++ Plus Data Structures

29

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 30: C++ Plus Data Structures

30

Integration Testing Approaches

Ensures correct overall design logic.

Ensures individual moduleswork together correctly, beginning with the lowest level.

TOP-DOWN BOTTOM-UP

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

Page 31: C++ Plus Data Structures

31

Practical Considerations

Page 32: C++ Plus Data Structures

32

Life-Cycle Verification Activities:

Analysis Design Code Test Delivery Maintenance