Object Oriented Software Engineering   View all facts   Glossary   Help
subject > problem > defect > defect in an ordinary algorithm
Next defectdefect in handling stress and unusual situations    Updefect    Previous defectdefect in a numerical algorithm   

defect in an ordinary algorithm comparison table
Subject have testing strategy cause by catch using has definition be hide until
incorrect logical conditionsusing equivalence class and boundary testing - to compute the equivalence classes, consider as an input each variable used in a rule or logical condition  A common defect in which the logical conditions that govern looping and if-then-else statements are wrongly formulated  
not handling null conditionsdetermine all possible null conditions and run test cases that would highlight any inappropriate behaviour  A common defect in which a program behaves abnormally when a null condition is encountered  
not handling singleton or non-singleton conditionsbrainstorm to determine unusual conditions and run appropriate tests  A common defect in which a program does not properly handle singleton conditions or non-singleton conditions  
not setting up the correct preconditions for an algorithmrun test cases in which each precondition is not satisfied - preferably its input values are just beyond what the algorithm can accept  A common defect in which a program proceeds to do its work even when specifies preconditions, that state what must be true before the algorithm should be executed, are not satisfied  
not terminating a loop or recursion
  • assume that the programmer has made an error
  • should analyse what causes a repetitive action to be stopped
  • should run test cases that the tester anticipates might not be handled correctly
  A common defect in which a loop or a recursion does not always terminate, i.e. it is 'infinite'  
off-by-one errordevelop boundary tests in which you verify that the program computes the correct numerical answer, or performs the correct number of iterations  A defect in which a program inappropriately adds or subtracts one, or inappropriately loops one too many times or one too few timesvery common especially in graphical applications 
operator precedence error
  • run tests that anticipate possible errors
  • use code inspections
  A defect in which a programmer omits needed parentheses, or puts parentheses in the wrong placeobviousspecial conditions arise
performing a calculation in the wrong part of a control construct
  • design tests that execute each loop zero times, exactly once, and more than once
  • ensure that anything 'bad' or 'unusual' that could happen while looping is made to occur on the first iteration and the last iteration
inappropriately excluding the action from, or including the action in, a loop or if-then-else constructblack-box testing, so glass-box testing or inspections may be more effectiveA common defect in which the program performs an action when it should not, or does not perform an action when it should  
use of an inappropriate standard algorithmdesign tests that highlight the properties of inappropriate algorithms such as execution time  A common defect in which an unnecessarily inefficient or otherwise inappropriate algorithm is used  

Next defectdefect in handling stress and unusual situations    Updefect    Previous defectdefect in a numerical algorithm