Week 9 Data structures / collections. Vladimir Misic Week 9 Monday, 4:20:52 PM2 Data structures (informally:) By size: –Static (e.g. arrays)

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Lecture 8: Testing, Verification and Validation
1 Integration Testing CS 4311 I. Burnstein. Practical Software Testing, Springer-Verlag, 2003.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Developer Testing and Debugging. Resources Code Complete by Steve McConnell Code Complete by Steve McConnell Safari Books Online Safari Books Online Google.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Illinois Institute of Technology
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Principle of Functional Verification Chapter 1~3 Presenter : Fu-Ching Yang.
Chapter 13 & 14 Software Testing Strategies and Techniques
Data Structures Data structures permit the storage of related data for use in your program. –Arrays.
1 Joe Meehean. 2 Testing is the process of executing a program with the intent of finding errors. -Glenford Myers.
Test Design Techniques
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
System/Software Testing
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.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Introduction Telerik Software Academy Software Quality Assurance.
CMSC 345 Fall 2000 Unit Testing. The testing process.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
1 Testing Course notes for CEN Outline  Introduction:  terminology and philosophy  Factors that influence testing  Testing techniques.
Software Testing Testing principles. Testing Testing involves operation of a system or application under controlled conditions & evaluating the results.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
Testing -- Part II. Testing The role of testing is to: w Locate errors that can then be fixed to produce a more reliable product w Design tests that systematically.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Queue What is a queue?. Queues A queue is similar to waiting in line for a service, e.g., at the bank, at the bathroom –The first item put on the queue.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
1 Software Testing Strategies: Approaches, Issues, Testing Tools.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Software Quality Assurance and Testing Fazal Rehman Shamil.
Dynamic Testing.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
SOFTWARE TESTING SOFTWARE TESTING Presented By, C.Jackulin Sugirtha-10mx15 R.Jeyaramar-10mx17K.Kanagalakshmi-10mx20J.A.Linda-10mx25P.B.Vahedha-10mx53.
SOFTWARE TESTING. SOFTWARE Software is not the collection of programs but also all associated documentation and configuration data which is need to make.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Testing Integral part of the software development process.
Week#3 Software Quality Engineering.
Software Testing Strategies for building test group
Software Testing.
Software Engineering (CSI 321)
Testing Tutorial 7.
Software Testing.
Software Testing Techniques
March 29 – Testing and Priority QUeues
Chapter 13 & 14 Software Testing Strategies and Techniques
Types of Testing Visit to more Learning Resources.
Lecture 09:Software Testing
Static Testing Static testing refers to testing that takes place without Execution - examining and reviewing it. Dynamic Testing Dynamic testing is what.
Chapter 10 – 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 Testing Strategies
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Presentation transcript:

Week 9 Data structures / collections

Vladimir Misic Week 9 Monday, 4:20:52 PM2 Data structures (informally:) By size: –Static (e.g. arrays) –Dynamic (e.g. vectors) By ordering: –Last In First Out (LIFO) –First In First Out (FIFO) –Priority

Vladimir Misic Week 9 Monday, 4:20:52 PM3 Data Structures Types of dynamic generic data structures are: Stacks Queues Lists Trees

Vladimir Misic Week 9 Monday, 4:20:52 PM4 What is a Stack? A stack is similar in concept to a pile of plates, books, blocks, boxes, etc. –The first item put on the stack is on the bottom of the stack. –All items added to the stack are placed on top of the previous item. –The last item put on the stack is on the top of the stack.

Vladimir Misic Week 9 Monday, 4:20:52 PM5 What is a Queue? A queue is similar to waiting in line for a service, e.g., at the bank, at the bathroom –The first item put on the queue is at the front of the queue. –All items added to the queue are placed behind of the previous items. –The last item put on the queue is at the back of the queue.

Vladimir Misic Week 9 Monday, 4:20:52 PM6 Queues Queues are called First-in First-out (FIFO) data structures. –The first person to enter the queue is the first person to be served, i.e., leave the queue. –The last person to enter the queue is the last one to be removed from it.

Vladimir Misic Week 9 Monday, 4:20:52 PM7 Queues Characteristics of queues: –Data can only be placed at the back of the queue. –Data can only be removed from the front of the queue. –Data can only be removed from the rear of the queue if there is only one item on the queue. –Data can not be removed from the middle of the queue without first removing all items in front of it.

Vladimir Misic Week 9 Monday, 4:20:52 PM8 Queue Behaviors The behavior of putting an item in the queue is called enqueue( ). –Enqueue 4 onto the queue. The behavior of removing and item from the queue is called dequeue( ). –Dequeue 4 from the stack. (Remember this only works if 4 is in the front of the queue.)

Vladimir Misic Week 9 Monday, 4:20:52 PM9 Example What queue exists after executing the following commands? –enqueue(3) –enqueue(6) –enqueue(8) –enqueue(1) –dequeue() –enqueue(14)

Vladimir Misic Week 9 Monday, 4:20:52 PM10 Queue Implementation The ability to use a queue is not built into Java like arrays; nor is it available in util –You can implement a queue in many different ways, e. g. using a list or an array.

Vladimir Misic Week 9 Monday, 4:20:52 PM11 Queue Implementation A queue class can be written using arrays that will simulate a queue in your programs. –A restriction of using arrays to implement a queue is that the total size of the queue is limited. »Why? »Can you define a method that will resize the array to hold a queue of any size?

Vladimir Misic Week 9 Monday, 4:20:52 PM12 Queue Implementation Can you write a program to implement the Queue class that holds data of any data type? How do we modify our queue implementation so that the queue will grow?

Vladimir Misic Week 9 Monday, 4:20:52 PM13 Palindrome Example A program that determines if a word is a palindrome using a stack and a queue. –A palindrome is a word that is spelled the same both forwards and backwards.

Week 9 Testing and debugging

Vladimir Misic Week 9 Monday, 4:20:52 PM15 Why testing and debugging? Software development has a “black eye” –Schedules and time-to-market pressure –Reliability and warranty issues –Rising costs –New technology and market demands Increased focus on security and safety –Poor results

Vladimir Misic Week 9 Monday, 4:20:52 PM16 What we know We must shift the focus from detection to prevention. Learn to look for the root cause Pareto Principle - 80% of the defects will cluster in 20% of the components or causes The more rigorously tested at the front end, the more reliable at the back end

Vladimir Misic Week 9 Monday, 4:20:52 PM17 Fixing defects is more error-prone than the original development. One in 4 fixes introduces another defect elsewhere Finding and fixing defects –accounts for most of maintenance costs –accounts for 50% or more of typical development costs –introduces a new risk. Fixing a defect late in the cycle introduces a significant risk Fixing errors

Vladimir Misic Week 9 Monday, 4:20:52 PM18 Cannot rely on compiler to find ALL errors! The number of errors at the first compile may be indicative of the number of defects still in code (Myers) What can’t the compiler find? –Logical errors

Vladimir Misic Week 9 Monday, 4:20:52 PM19 What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.

Vladimir Misic Week 9 Monday, 4:20:52 PM20 What is Debugging? Debugging is the process of finding the source of errors and fixing such errors. –Testing is done before debugging.

Vladimir Misic Week 9 Monday, 4:20:52 PM21 Why Test? The purpose of testing is to identify implementation errors before the product is shipped. The errors may be: –Actual bugs in the code. –Incorrect implementation of the requirements or functional specifications. »Misunderstandings »Incomplete requirements or functional specifications.

Vladimir Misic Week 9 Monday, 4:20:52 PM22 What Testing is not Testing is not a random process. –There is a rhyme and reason to the process. Testing is not debugging. –Testing identifies the problems. –Debugging finds the location of a problem and fixes the problem.

Vladimir Misic Week 9 Monday, 4:20:52 PM23 Who is responsible for Testing? Multiple people are responsible for testing a system. –Initially the programmers are responsible for testing their implementation but this is not systems testing. –Usually a testing team will perform the majority of the tests, particularly at the system level. –The customer will also test the entire system. »Alpha and Beta testing.

Vladimir Misic Week 9 Monday, 4:20:52 PM24 Who is responsible for Debugging? There is also a number of people who are responsible for debugging. –If there is a testing team responsible for testing the system, this team will also attempt to precisely identify the problem and report it to the appropriate programmer. –The programmer is responsible for determining the actual problem and repairing it. –The customer should not debug a system.

Vladimir Misic Week 9 Monday, 4:20:52 PM25 When does Testing begin? Testing begins during the implementation phase. –The programmer is responsible for testing their unit to ensure the code meets the design and functional specifications. –As multiple units become available and can be combined, system testing can begin by the testing team. »It is not unusual for implementation and testing phases to overlap. This is particularly true with today’s shorter development cycles.

Vladimir Misic Week 9 Monday, 4:20:52 PM26 What is tested? The system is tested by: –Units of the system. »In object oriented programming the classes would be tested. –Related units of the system. –The entire system.

Vladimir Misic Week 9 Monday, 4:20:52 PM27 How are Tests Passed? A system passes the tests if it produces results that are consistent with the functional specification and requirements. –The program does what it is supposed to do. –The program does not do anything it is not supposed to.

Vladimir Misic Week 9 Monday, 4:20:52 PM28 How are Tests Passed? If any single unit test fails, then the entire system is not correct. If all unit tests pass, then there is a good probability that the entire system will work together.

Vladimir Misic Week 9 Monday, 4:20:52 PM29 Types of Testing Formal verification is a process that uses mathematical and logical assertions to prove that the program is correct. –Formal verification is difficult to do.

Vladimir Misic Week 9 Monday, 4:20:52 PM30 Types of Testing Empirical testing is the process of generating test cases and running the tests to show that errors exist. Empirical testing involves observing the results of using the system. –Empirical testing can only prove that an error exists. It can not prove that there are no errors. There are two types of Empirical Testing: white box and black box testing.

Vladimir Misic Week 9 Monday, 4:20:52 PM31 Empirical Testing –White box testing: »Requires access to the actual implementation code. »Requires the development of test cases that will exercise each unit of the system, and possible “flows” through the system based upon the actual implementation. All statements, all decisions, all conditions, and all inputs. »This type of testing is not very practical but sometimes it is required.

Vladimir Misic Week 9 Monday, 4:20:52 PM32 Empirical Testing –Methodologies that are used for White Box testing are: »Statement coverage »Decision coverage »Condition coverage »Decision/condition coverage »Multiple-condition coverage

Vladimir Misic Week 9 Monday, 4:20:52 PM33 Empirical Testing –Black Box Testing: »Typically a testing team develops use cases based upon the requirements and functional specification without looking at the actual implementation. »Tests valid and invalid inputs but can not possibly test all inputs. Must determine what subset of inputs will sufficiently cover all inputs. »You want to break the system, it is your job with Black Box Testing.

Vladimir Misic Week 9 Monday, 4:20:52 PM34 Empirical Testing –Methodologies for Black Box Testing: »Equivalence partitioning: A set of inputs that are processed identically by the program –Legal input values –Numeric/non-numeric values »Boundary Testing »Error Guessing

Vladimir Misic Week 9 Monday, 4:20:52 PM35 Testing Formal verification Empirical testing White Box testing Black Box testing Statement coverage Decision coverage Condition coverage Decision/condition coverage Multiple-condition coverage Statement coverage Decision coverage Condition coverage Decision/condition coverage Multiple-condition coverage Equivalence partitioning Boundary Testing Error Guessing Equivalence partitioning Boundary Testing Error Guessing

Vladimir Misic Week 9 Monday, 4:20:52 PM36 Testing Statement Coverage Statement coverage tests that each statement in the system is executed at least once by the test data. –Testing the statement coverage is necessary but is not sufficient.

Vladimir Misic Week 9 Monday, 4:20:52 PM37 Testing Statement Coverage What problems can you find? Assume that a = 2, b = 2, and that x is properly defined and initialized. if (a > 1) && (b == 2){ x = x / a; } if (a == 2) || ( x > 1) { x++; } if (a > 1) && (b == 2){ x = x / a; } if (a == 2) || ( x > 1) { x++; }

Vladimir Misic Week 9 Monday, 4:20:52 PM38 Testing Decision Coverage Testing for Decision Coverage requires testing every decision for both a true and false outcome.

Vladimir Misic Week 9 Monday, 4:20:52 PM39 Testing Decision Coverage a) Assume: a = 2, b = 2, x > 1 b) Assume: a = 1, b = 2, x = 0 if (a > 1) && (b == 2){ x = x / a; } if (a == 2) || ( x > 1) { x++; } if (a > 1) && (b == 2){ x = x / a; } if (a == 2) || ( x > 1) { x++; }

Vladimir Misic Week 9 Monday, 4:20:52 PM40 Testing Decision Coverage Testing for Decision Coverage also tests for statement coverage in modern languages. –This is not true of languages that have multiple entry points, contain self-modifying code, etc.

Vladimir Misic Week 9 Monday, 4:20:52 PM41 Testing Condition Coverage Testing Condition Coverage requires testing each possible outcome for every condition within a decision at least once. –The Decision Coverage testing we did only covered half of the cases in the previous example. »The cases are: a > 1 (1) b == 2 (2) a == 2 (3) x > 1 (4)

Vladimir Misic Week 9 Monday, 4:20:52 PM42 Testing Condition Coverage a) Assume: a = 2, b = 2, x = 4 b) Assume a = 1, b = 3, x = 1 if (a > 1) && (b == 2){ x = x / a; } if (a == 2) || ( x > 1) { x++; } if (a > 1) && (b == 2){ x = x / a; } if (a == 2) || ( x > 1) { x++; }

Vladimir Misic Week 9 Monday, 4:20:52 PM43 Multiple-Condition Coverage Testing for Multiple-condition coverage requires test cases that test all possible combinations of condition outcomes for every decision tested. –This type of testing will generate many test cases.

Vladimir Misic Week 9 Monday, 4:20:52 PM44 Debugging Debugging should be a formal process of attempting to narrow down the location of the problem and then identifying the problem. –Debugging does not mean simply changing code until the problem goes away. –Debugging requires thinking about what might be the problem.

Vladimir Misic Week 9 Monday, 4:20:52 PM45 Debugging Methods of determining the location of a bug: –Use extra output statements in the program to trace the program execution. –Use a debugger to trace the program execution. –Possibly write special test code to exercise parts of the program in special ways that will allow you to better understand the error.

Vladimir Misic Week 9 Monday, 4:20:52 PM46 Debugging –Potentially test a certain range of values to see which ones fail. –Attempt to eliminate parts of the program as the problem, thus narrowing your search. –Check that the data is valid. –Many times, the location where you see the first instance of the bug is not the source of the bug.

Vladimir Misic Week 9 Monday, 4:20:52 PM47 Fixing Bugs Steps for fixing bugs: –Fix only one bug at a time and then rerun the same exact tests. »Changing multiple things makes id difficult to identify which change caused the behavior change. –If the problem appears to be fixed, still run a full test suite to ensure the “fix” did not break something else.

Vladimir Misic Week 9 Monday, 4:20:52 PM48 General Rules to follow Test your code as your write it: –Test the code boundaries. –Test pre- and post- conditions. »The necessary or expected properties before and after the code is executed. –Use assertions (if you are programming in C or C++) –Program defensively by adding code to handle the “can not happen” cases. –Check error returns

Vladimir Misic Week 9 Monday, 4:20:52 PM49 General Rules to Follow Steps for Systematic Testing –Test incrementally by writing part of the system, test it, then write some more code, test that code, etc. –Test the simple parts of the system first. –Know what output you are expecting. –Compare independent implementations of a library or program provide the same answers.

Vladimir Misic Week 9 Monday, 4:20:52 PM50 General Rules –Ensure that testing covers every statement of the program. »Every line of the program should be exercised by at least one test.