Problem Analysis and Program Design

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Advertisements

COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Programming Logic and Design, Third Edition Comprehensive
Testing an individual module
Modules, Hierarchy Charts, and Documentation
Chapter 1 Program Design
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
The Program Design Phases
PRE-PROGRAMMING PHASE
Adding Automated Functionality to Office Applications.
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
28/08/2015SJF L31 F21SF Software Engineering Foundations ASSUMPTIONS AND TESTING Monica Farrow EM G30 Material available on Vision.
REPETITION STRUCTURES. Topics Introduction to Repetition Structures The while Loop: a Condition- Controlled Loop The for Loop: a Count-Controlled Loop.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
1 Shawlands Academy Higher Computing Software Development Unit.
Programming Translators.
CMSC 345 Fall 2000 Unit Testing. The testing process.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Program Development Life Cycle (PDLC)
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
Creating your first C++ program
1 IPC144 Session 4 Flowcharts. 2 Objectives: By the end of this session, the student will be able to: List the three elements of the Structure Theorem.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Testing Methods Carl Smith National Certificate Year 2 – Unit 4.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.
Software Development Process.  You should already know that any computer system is made up of hardware and software.  The term hardware is fairly easy.
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
1 Loops. 2 Topics The while Loop Program Versatility Sentinel Values and Priming Reads Checking User Input Using a while Loop Counter-Controlled (Definite)
Intermediate 2 Software Development Process. Software You should already know that any computer system is made up of hardware and software. The term hardware.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer.
The Software Development Process
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
Intermediate 2 Computing Unit 2 - Software Development.
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
Controlling Program Flow with Decision Structures.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
IPC144 Session 4 Flowcharts 1. Objectives: By the end of this session, the student will be able to: List the three elements of the Structure Theorem Identify.
Algorithms and Pseudocode
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
ICS124 Session 9 Flowcharting 1. By the end of this section the student will be able to:  Name the three structures of the Structure Theorem  Identify.
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
IPC144 Session 4 Flowcharts 1. Objectives: By the end of this session, the student will be able to: List the three elements of the Structure Theorem Identify.
Algorithms and Flowcharts
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Topics Introduction to Repetition Structures
Introduction To Flowcharting
Print slides for students reference
Designing and Debugging Batch and Interactive COBOL Programs
Unit# 9: Computer Program Development
Lecture 09:Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Software Development Process
Automated test.
Basic Concepts of Algorithm
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Automated test.
Presentation transcript:

Problem Analysis and Program Design IPC144 Session 5 Problem Analysis and Program Design Continued 1

Synthesize a Test Plan from test data Objectives Design good test data Synthesize a Test Plan from test data Apply a rigorous approach to testing flowcharts using Walkthroughs 2

Test Data Test Data From the PDC: PDC: Test the Algorithm for Correctness One of the most important steps Identifies major logic errors Walkthroughs are a technique for testing Test plans are used to document and plan the tests necessary to prove your algorithm performs as required 3

Test Data, continued Test Data, continued There could exist an infinite number of possible values that a program can accept as input. For example, write a program that accepts three numbers, adds them together and displays their total and average. There are an infinite number of possible input values- does this mean that we must try all possible values to ensure that the program works correctly? There must be a reasonable set of test data we can use to prove the algorithm works empirically. 4

Test Data, continued Test Data, continued There are two general types of testing: Black Box Testing White Box testing 5

Test Data, continued Black box testing The system, or program, is tested without knowing what is inside it Tests are developed based solely on the requirements statement - based on the inputs, what are the expected outputs Used to test the system or a multi-module program as a whole Can be used to help clarify the requirements statement as you find test data that does not appear to be accounted for in the requirements 6

Test Data, continued White box testing The algorithm is tested knowing what is inside it It can only be developed by a programmer (typically the programmer that created the software)‏ Everything about the program is known- therefore everything is tested for You must test every possible program instruction and every possible situation. 7

Test Data, continued White box testing, continued Start identifying test data during the Design Phase As you build your flowchart & pseudocode look for test cases, document them as you find them Look for unusual conditions / situations to be added to your testing As you find conditions that are not handled by your algorithm- enhance your algorithm and add the test to your Test Plan. What is good test data for both Black Box Testing and White Box Testing? What do we look for? 8

Test Data, continued Test Data Black Box Look at requirements Get test data and expected results from the user. What if user ends program as their first action? Unexpected values (user types words instead of a number)‏ White Box Look at the Program and how it was written Define data that will result in all branches of all decisions being tested Ensure that ranges are tested for their minimum and maximum values Look for ways that a divide by zero may happen Simulate all possible error conditions (even if you have to alter your program to ensure they occur)‏ 9

Test Plans Test Plans Why all the trouble? User groups and Audit departments look for them Provides a concise description of WHAT was tested Provides a concise description of HOW it was tested Provides a concise description of the ENVIRONMENT it was tested in A well design and documented test plan can break the 'finger pointing' 10

Test Plans, continued Test Plans, continued Provides a concise description of WHAT was tested At some time software comes under scrutiny: The system has failed - was this scenario tested? Somebody (maybe you) months later asks the question was ______ tested? 11

Test Plans, continued Test Plans, continued Provides a concise description of HOW it was tested What were the test cases? What data was used? Was certain sequence of events tested for? Again, a system failure may precipitate the question: Was this sequence of events tested for? 12

Test Plans, continued Test Plans, continued Provides a concise description of the ENVIRONMENT is was tested in What other programs where part of the package? What was the version of these other programs? What hardware was it tested on? What was the version of the operating system? It "NEVER" happens that after you have certified a system somebody changes a component and doesn't tell you! 13

Test Plans, continued Test Plans, continued An example of the parts of a Test Plan: Cover Page Environment setup Black Box Testing White Box Testing (can include “negative tests” to ensure the program does not crash or have undesired side-effects) 14

Test Plans, continued Test Plans - Cover Page A brief description of what the program or system does. Not too technical - just enough that somebody non-technical can understand what the program does An extract of the requirements statement may form part of the cover page 15

Test Plans, continued Test Plans - Environmental Setup Optional – depending on nature of your work environment More technical description What hardware is being used (as specific as necessary)‏ What version of the operating system is being used What is the version of YOUR program that is being tested The files that are used to makeup your program What are the versions of the other programs that interface with yours Are there versions of test data files? 16

Test Plans, continued Test Plans - Black Box Testing These tests are to ensure that the program meets the requirements statement Predominately positive testing is performed Hopefully the Business Analyst has provided test cases that can be incorporated into the Test Plan Concentrate on obtaining the correct outputs for the test inputs Each test has two parts: the test, the expected results 17

Test Plans, continued Test Plans - White Box Testing These tests are to ensure that the program handles all expected and unexpected data Every path within the program must (at least in this course) be tested. Can become very complex with the inter-relationships between variables One philosophy behind White Box Testing is that "it would be nice that whenever a program prompts a user for a number, the users always enter a legitimate value that the program can handle" May require modifications to the code to simulate error conditions (be sure to perform these modifications and tests on a COPY of the program)‏ Each test has two parts: the test, the expected results 18

Test Plans, continued Test Plans - Negative Testing The intent is to maliciously attack your code - to see where (if) is breaks Can be an easy task or frustrating task depending on how well constructed the code is You will normally have built into your code a means to detect error conditions The goal of your program is to shut down gracefully (return an error code or error message) as opposed to crashing or affecting other programs or systems 19

Test Plans, continued Example Write a program to help a local Elementary School's library with the overdue fines on books. The librarians don't wish to always charge students for overdue books, however sometimes the number of books that are overdue is too much. When this happens the librarians enter into the program the student's name, the name of the overdue book they borrowed, and the date it was signed out (the librarian reads these fields from the sign-out card). The colour of the card is also entered, as this indicates what the normal sign-out period is for that book. White cards are due back in 14 days, Blue cards in 7 days, Green cards the next day, and Orange cards in 28 days. The colour code of the card is entered as a single character into the program (W, B, G and O). When this information has been entered, the program determines by how much the book is overdue (based on the date the program is run) and the overdue charge, ($0.05 per day). A list is produced that will show the student's name, the name of the book, the number of days the book is overdue and the fine that is payable. 20

Test Plans, continued Library Fines Test Plan The program is a tool that will allow librarians to assess fines on overdue library books. The fine is calculated as $0.05 / day. The fines are based on the colour code of the sign-out cards, where: Orange Cards - 28 day sign-out period White Cards - 14 day sign-out period Blue Cards - 7 day sign-out period Green Cards - 1 day sign-out period The librarian is responsible for entering the student name, book name and the sign-out date. 21

Test Plans, continued Environmental Setup Program and Version: library.c Version 1.0 Hardware: IBM RS/6000 O/S: AIX 4.3 Compiler: cc Other files: no other files are required 22

Test Plans, continued Black Box Testing 1) Enter 'Stu1', 'Book1', 'O', today's date - 30 Expected result: overdue = 2, fine = $0.10 2) Enter 'Stu2', 'Book2', 'W', today's date - 30 Expected result: overdue = 16, fine = $0.80 3) Enter 'Stu3', 'Book3', 'B', today's date - 30 Expected result: overdue = 23, fine = $1.15 4) Enter 'Stu4', 'Book4', 'G', today's date - 30 Expected result: overdue = 29, fine = $1.45 5) Enter 'Stu5', 'Book5', 'G', today's date Expected result: overdue = 0, fine = $0.00 23

Test Plans, continued White Box Testing 1) Enter a colour code other than 'O', 'W', 'B', 'G'. Expected Result: error message “Invalid card colour code entered”. Program to prompt for the colour code again. 2) Enter a future date (i.e. the book is not yet overdue) Expected Result: error message “Invalid Future date entered”. Program to prompt for the date again. 24

Walkthroughs Walkthroughs Walkthroughs are a means to test the algorithm BEFORE it has been coded Walkthroughs are a tool to test that your algorithm behaves correctly Because the computer is a mindless automaton - in order to check the program YOU must become the mindless automaton! You 'play computer' - turn OFF your mind and follow the instructions EXACTLY as written Remember to follow the instructions and perform what is asked for, not what you want to happen 25

Walkthroughs, continued It is hard to keep track of the many variables in a program, so take a sheet a paper: List the variables, and their values. Keep track of the new values of a program as you execute the instructions For output, reserve a space on your paper to track any information that is displayed to the user. This can be very tough, as it is very easy at this stage to execute the instructions as you WANT them to be executed. When we talk about pseudo code, walkthroughs can be used to test the INTEGRITY of the code after it has been translated from flowcharts to pseudo code. 26

Walkthroughs, continued start Walkthroughs, continued num = 1 var = 0 var = num+ var DISPLAY var num = num + 2 num <= 7 TRUE FALSE stop 27

Walkthroughs, continued Start i > 0 i = 5 Stop FALSE TRUE f = f * j j = i j > 1 j = j - 1 i = i - 1 f = 1 DISPLAY “Done” DISPLAY f Walkthroughs, continued 28