Curriculum Portal

Select a course.

arrow_back

2.3 Producing Robust Programs

infoWhy this? Professional software must be reliable, secure and user-friendly. Studying defensive design and testing helps you understand how programmers minimise errors and create dependable products.

scheduleWhy now? Learning these skills now encourages good programming habits from the outset and reinforces the importance of quality and accuracy in software development.

neurologyYou need to know

  • Defensive design anticipates how users might accidentally or deliberately misuse a program and reduces the risk of incorrect, unsafe or insecure operation.
  • A program should cater for all likely inputs, including valid values, values at permitted limits, invalid values and values of the wrong data type.
  • Input validation checks that entered data satisfies predefined rules before the program processes it.
  • Common validation checks include range checks, type checks, length checks, presence checks and format checks.
  • Validation can reject unsuitable data, but it cannot guarantee that accepted data is factually accurate.
  • Invalid input should be rejected with a clear error message and the user should normally be given an opportunity to enter the data again.
  • Authentication confirms a user's claimed identity, commonly by checking a username and password against stored credentials.
  • Passwords should not be displayed as plain text during entry or stored as plain text because this could expose users' credentials.
  • Maintainability is the ease with which a program can be understood, corrected, tested and modified.
  • Subprograms divide a program into smaller modules, reducing repetition and allowing individual sections to be developed, tested and reused.
  • Meaningful and consistent names for variables, constants and subprograms make their purposes easier to identify.
  • Consistent indentation shows the structure of selection, iteration and subprograms, making code easier to read and debug.
  • Comments explain the purpose or reasoning behind important sections of code and should add useful information rather than restating obvious instructions.
  • Testing is used to find syntax errors, logic errors and unmet requirements before a program is released or used.
  • Iterative testing takes place throughout development as individual modules and changes are tested, whereas final or terminal testing checks the completed program at the end of production.
  • A syntax error breaks the grammatical rules of a programming language and prevents the program from being translated or run successfully.
  • A logic error allows a program to run but causes it to produce an incorrect or unexpected result.
  • Normal test data is valid data that the program should accept and process without errors.
  • Boundary test data has the correct data type and lies at, or immediately around, the limits of the valid range.
  • Invalid test data has the correct data type but should be rejected, whereas erroneous test data has the wrong data type and should also be rejected.

rocket_launchYou must be able to

  • Anticipate likely accidental and deliberate misuse by identifying risky inputs and designing suitable validation or access controls.
  • Design validation routines that check relevant rules, reject unsuitable data with a clear message and allow the user to try again.
  • Implement simple authentication by comparing entered credentials with authorised credentials and denying access when they do not match.
  • Decompose a program into purposeful subprograms with meaningful names, consistent indentation and appropriate comments.
  • Identify syntax errors from code or diagnostic messages and correct the language rules that have been broken.
  • Trace a running program to identify logic errors by comparing actual values and outputs with the intended algorithm.
  • Select normal, boundary, invalid and erroneous test data for a scenario, including values at and immediately outside each permitted limit.
  • Create and complete a test plan containing the test data, test type, reason for the test, expected result, actual result and pass or fail outcome.
  • Refine an algorithm or program in response to test results, then retest affected modules and the completed program.


Revision Quiz

trophy Congratulations! You have completed the quiz.