Defensive design considerations part 1 Flashcards
What is input validation in programming?
Input validation checks if data input by the user meets specific criteria or rules before processing.
What are the 5 types of input validation?
- Type check 2. Range check 3. Presence check 4. Format check 5. Length check
What is a type check in input validation?
Ensures the input is of the correct data type
What is a range check in input validation?
A range check ensures the data is in the correct range
What is a presence check in input validation?
A presence check ensures that mandatory or required data has been entered
What is a format check in input validation?
A format check ensures the data input is in the correct format
What is a length check in input validation?
A length check ensures the input has the correct (or minimum/maximum) number of characters
How does input validation make a program more robust?
It prevents errors by ensuring data meets specific criteria before processing
Why is anticipating misuse important in defensive design?
It helps prevent crashes or errors caused by unexpected user actions or inputs.
What is a common example of anticipating misuse in programming?
Checking for division by zero to avoid program crashes.