8.2 Defensive design Flashcards
What is data validation?
A routine that ensures that data entered is of the right types - for example an integer
Give the different types of validation checks
Range check, type check, length check, presence check, format check
Range check
A number or date is within a sensible/ allowed range
Type check
Data is of the right type
Length check
Text entered is not too long or too short
Presence check
Checks that data has been entered
Format check
Checks that the format of the input is correct
Difference between Validation and verification
Validation can only check that data entered is reasonable. Verification is used to double-check that the data has been typed in correctly
Authentication routines
Authentication routines are used to make sure a person is who they claim to be
Why should you maintain programs?
To improve code, fix bugs or add new features to the program
What can you do with your code to improve maintability?
Subprograms, using appropriate naming conventions, indentation and commenting
Give examples of subprograms
Functions and procesdures
What are comments usually written for
Parts of a program that are difficult to understand. At the start of a function or procedure to explain what it does
When to not use comments
Every line of code. To explain parts that are obvious. To explain syntax used in the programming language