Week 1 Resit Flashcards
Generalisation
solving a more general problem than initially required to improve reusability and insightcan be carried out via parameters as they hide the identity of the data operated on
Mistakes vs Defects/Faults vs Failures vs Errors in Engineering
Humans can make a mistake in engineering, which then causes a defect/fault in their creation.This defect/fault is an anomaly in the system that causes a system failure.The failure occurs when the product deviates from its requirements in operation, leading to an error.Error is the difference between actual and expected result.
Some properties of defects:
the longer a defect is undiscovered, the higher its costdefects decrease the predictability of a projectdefects create risksdefects are increasingly likely for increasingly large systems
Some engineering mistakes:
mistunderstanding the customer
misinterpreting a written requirement
overlooking a case in analysing the requirements
adopting an incorrect algorithm
making an unwanted assumption when implementing a method
making a typing error when entering code
How to deal with mistakes:
admit that people make mistakes and inject defects (awareness)
prevent them as much as possible
minimise consequences (defensive programming, fault tolerance)
detect presence of defects as early as psosible
localise defects
repair defects
trace defects
learn from defects
Fault tolerance
the system’s ability to continue functioning properly and reliably in the presence of errors or failures, often achieved through techniques like error detection, recovery mechanisms, and redundancy
Reviewing vs testing
Reviewing:
examining an artefact with the intent of finding defects
- often localises the defects as well
- can be done early in the development process
Testing:
using a product systematically with the intent of finding defects
- does not localise underlying defects- requires a working product
Limitations of testing:
does not create quality, only measures itcan show the presence of bugs, but unlikely their abscence
Debugging
process of localising, diagnosing and correct detected defects
Techniques for constructing test cases
Boundary analysis
Equivalence classes
Statement, branch and path coverage
Random input
Objects not listed in @modifies not modified
Testing for precondition violations
Boundary analysis
picking values near and on the boundaries
Equivalence classes
picking elements from every equivalence class
Statement, branch and path coverage
Statement coverage: measures the percentage of executable code statements that have been executed during a particular test; focuses on ensuring that each line of code has been executed at least once during testingBranch coverage: evaluates the execution of different branches (decision points) in the code; aims to test both the true and false outcomes of decision points (if statements, loops, etc.).Path coverage: measures the percentage of unique paths through the code that have been executed; goes beyond statement and branch coverage by considering the specific combinations of branches and decision points taken during execution
Methods of deciding on pass vs fail:
Selecting trivial or highly structured input with known outputManually determining expected outputChecking correctness of output via inverse methodUsing alternate implementation to compute expected output
Dealing with violated preconditions
Do nothing, leave it up to the callerReturn special result that conveys wrong inputUse exceptions (recommended)