Chapter 1 Software Engineering Principles. Lecture 2.

Slides:



Advertisements
Similar presentations
C++ Plus Data Structures
Advertisements

COSC 120 Computer Programming
1 Lecture-4 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
Important Definitions Class: A structured data type that is used to represent an abstract data type (ADT) Class member: A components of a class. It can.
1 Lecture 19 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
Lecture 18:Topic: I/O Formatting and Files Dale/Weems/Headington
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
C++ plus. 2 Goals Some general C++ tips 3 C++ Tips is header file for a library that defines three stream objects Keyboard an istream object named cin.
Chapter 1 Principles of Programming and Software Engineering.
Chapter 1 Software Engineering. Homework ► Read Section 2.2 (pages 79-98) ► Answer questions: ► 7, 8, 11, 12, & 13 on page 134. ► Answer on paper, hand.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
SW Engineering. 2 Goals Describe the general activities in the software life cycle Describe the goals for "quality" software Explain the following terms:
1 Programming Style Files Lecture 1 Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Modified by Reneta Barneva, SUNY-Fredonia.
Chapter 3: Input/Output
Program Input and the Software Design Process ROBERT REAVES.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics.
Modular Programming Chapter Value and Reference Parameters computeSumAve (x, y, sum, mean) ACTUALFORMAL xnum1(input) ynum2(input) sumsum(output)
1 Chapter 4 Program Input and the Software Design Process.
1 Chapter-01 Programming Methodologies Procedural/Structured Design Objected-Oriented Design.
1 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
1 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
1 Chapter 4 Program Input and the Software Design Process CS185/09 - Introduction to Programming Caldwell College.
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
File I/O ifstreams and ofstreams Sections 11.1 &
Chapter 9 I/O Streams and Data Files
File Input and Output in C++. Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) Keyboard Screen executing program input data.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
Disk Files for I/O your variable (of type ifstream) your variable (of type ofstream) disk file “myInfile.dat” disk file “myOut.dat” executing program input.
1 Chapter 4 Program Input and the Software Design Process Dale/Weems.
No I/O is built into C++ l instead, a library provides input stream and output stream KeyboardScreen executing program istreamostream 1.
1 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
1 Program Input Software Design Chapter 4. 2 You Will Want to Know... Prompting for and reading values into a program. Accessing data from a file. What.
1 Chapter 4 Program Input and the Software Design Process Dale/Weems/Headington.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Program Input and the Software Design Process. 2 Chapter 4 Topics  Input Statements to Read Values for a Program using >>, and functions get, ignore,
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Operating System Using setw and setprecision functions Using setiosflags function Using cin function Programming 1 DCT
Data Structure Introduction Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2010.
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
Chapter 4 Program Input and the Software Design Process.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Input/Output. Objectives In this chapter you will: Learn what a stream is and examine input and output streams Explore how to use the input stream functions.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
1 Chapter 4 Program Input and the Software Design Process.
Chapter 2 Principles of Programming and Software Engineering.
1 Stream Input and Output Read Text, page Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) KeyboardScreen executing.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
Chapter 4 Program Input and the Software Design Process
Principles of Programming & Software Engineering
What Actions Do We Have Part 1
C++ Plus Data Structures
Chapter 1 Data Abstraction: The Walls
About the Presentations
Chapter 1 Software Engineering Principles
File I/O.
Chapter 1 Software Engineering.
Lecture 5A File processing Richard Gesick.
Chapter 3: Input/Output
No I/O is built into C++ instead, a library provides input stream and output stream Keyboard Screen executing program istream ostream 1.
Chapter 3 Input output.
Chapter 4 Program Input and the Software Design Process
Dale/Weems/Headington Program Input and the Software Design Process
Presentation transcript:

Chapter 1 Software Engineering Principles

Lecture 2

Problem analysis Requirements elicitation Software specification High- and low-level design Implementation Testing and Verification Delivery Operation Maintenance CS Software Engineering Principles 3 The Software Life Cycle

CS Software Engineering Principles 4 Waterfall Model

CS Software Engineering Principles 5 Spiral Model

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 CS Software Engineering Principles 6 Software Engineering

A logical sequence of discrete steps that describes a complete solution to a given problem computable in a finite amount of time CS Software Engineering Principles 7 An Algorithm Is...

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 CS Software Engineering Principles 8 Programmer ToolBoxes

It works It can be modified without excessive time and effort It is reusable It is completed on time and within budget CS Software Engineering Principles 9 Goals of Quality Software

Tells what the program must do, but not how it does it Is written documentation about the program CS Software Engineering Principles 10 Detailed Program Specification

A model of a complex system that includes only the details essential to the perspective of the viewer of the system Programs are abstractions CS Software Engineering Principles 11 Abstraction

CS Software Engineering Principles 12 Abstraction (cont.)

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 CS Software Engineering Principles 13 Information Hiding

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 Round-trip gestalt design CS Software Engineering Principles 14 Stepwise Refinement

CS Software Engineering Principles 15 Visual Tools

CS Software Engineering Principles 16 Visual Aids – CRC Cards

“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,” CS Software Engineering Principles 17 Procedural vs. Object-Oriented Code

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 FUNCTIONAL DECOMPOSITION OBJECT-ORIENTED DESIGN FOCUS ON: processes FOCUS ON: data objects 18 CS Software Engineering Principles Approaches to Building Manageable Modules

CS Software Engineering Principles 19 Functional Design Modules Find Weighted Average Print Weighted Average Main Print Data Print Heading Get Data Prepare File for Reading

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 CS Software Engineering Principles 20 Object-Oriented Design Private data << setf Private data >> get ignore cin cout

Testing: The process of executing a program with data sets Debugging: The process of removing known errors Acceptance Test: The process of testing the system in its real environment with real data Regression Testing: Reexecution of program tests after modifications have been made Verification of Software Correctness CS Software Engineering Principles 21

CS Software Engineering Principles 22 Verification

CS Software Engineering Principles 23 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.

Specification Design Coding Input CS Software Engineering Principles 24 Types of Errors

25 CS Software Engineering Principles

26 Cost of a Specification Error Based on When It Is Discovered

Lecture 3

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 CS Software Engineering Principles 28 Controlling Errors

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 CS Software Engineering Principles 29 Design Review Activities

Program Testing CS Software Engineering Principles 30

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 CS Software Engineering Principles 31 Program Testing (con't)

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 CS Software Engineering Principles 32 Types of Testing

33 CS Software Engineering Principles

34 CS Software Engineering Principles

Is performed to integrate program modules that have already been independently unit tested. CS Software Engineering Principles 35 Integration Testing Find Weighted Average Print Weighted Average Main Print Data Print Heading Get Data Prepare File for Reading

Integration Testing Approaches CS Software Engineering Principles 36 Ensures correct overall design logic. Ensures individual modules work together correctly, beginning with the lowest level. TOP-DOWN BOTTOM-UP USES: placeholder USES: a test driver to call module “stubs” to test the functions being tested. the order of calls.

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 CS Software Engineering Principles 37 Test Plans

CS Software Engineering Principles 38 Testing C++ Structures

Declare an instance of the class being tested Get name and open input file Get name and open output file Get 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 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 39 CS Software Engineering Principles

40 Life-Cycle Verification Activities

#include using namespace std; CS Software Engineering Principles 41 Keyboard and Screen I/O cin (of type istream) cout (of type ostream) KeyboardScreen executing program input data output data

In slides that follow, assume the statement: using namespace std; We explain namespace in Chapter 2 CS Software Engineering Principles 42 namespace

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) CS Software Engineering Principles 43 is header file

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 ). CS Software Engineering Principles 44 Insertion 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. CS Software Engineering Principles 45 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. cin.get(inputChar); CS Software Engineering Principles 46 Extraction Operator >>

47 #include 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; } CS Software Engineering Principles

#include CS Software Engineering Principles 48 Disk files for I/O your variable (of type ifstream) your variable (of type ofstream) disk file “myInfile.dat” disk file “myOut.dat” executing program input dataoutput data

use #include 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 CS Software Engineering Principles 49 For File I/O

Statements for using file I/O #include using namespace std; ifstream myInfile; // declarations ofstream myOutfile; myInfile.open(“myIn.dat”); // open files myOutfile.open(“myOut.dat”); myInfile.close( ); // close files myOutfile.close( ); 50 CS Software Engineering Principles

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 CS Software Engineering Principles 51 What does opening a file do?

#include int main( ) { // USES FILE I/O using namespace std; int partNumber; float unitPrice; ifstreaminFile; // declare file variables ofstreamoutFile; inFile.open(“input.dat”);//open files outFile.open(“output.dat”); inFile >> partNumber ; inFile >> unitPrice ; outFile << “Part # “ << partNumber // echo << “at Unit Cost: $ “ << unitPrice << endl ; return 0; } 52 CS Software Engineering Principles

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 does not exist opening an output file on a disk that is already full or is write-protected. CS Software Engineering Principles 53 Stream Failure

#include using namespace std; int main( ) {// CHECKS FOR STREAM FAIL STATE ifstreaminFile; inFile.open(“input.dat”);// try to open file if ( !inFile ) { cout << “File input.dat could not be opened.”; return 1; }... return 0; } 54 CS Software Engineering Principles