WS3. Defensive Programming

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering core concepts of defensive programming, input validation strategies, error-handling methods, exceptions, runtime AI safety, and production code practices.

18 Terms

1
New cards

Defensive Programming

A programming methodology based on the recognition that programs will encounter problems and modifications, structuring code so that a routine is protected from damage even if invalid data is passed due to another routine's fault.

2
New cards

Garbage In, Nothing Out

An input protection approach where invalid data passed into a routine is silently ignored without crashing the application or returning invalid results.

3
New cards

Garbage In, Error Message Out

An input protection approach where receiving invalid data causes the software to suppress execution and emit an explicit error message.

4
New cards

No Garbage Allowed In

An input protection approach where inputs are screened and re-prompted in a validation loop until they strictly meet required criteria before any processing can occur.

5
New cards

Returning a Neutral Value

An error-handling technique where bad data is countered by continuing execution and returning a known harmless value, such as 0 for a numeric calculation, an empty string, or an empty pointer.

6
New cards

Substituting the Next Piece of Valid Data

An error-handling technique used during stream or database processing where corrupted records are skipped to continue reading until the next valid record is found.

7
New cards

Returning the Same Answer as the Previous Time

An error-handling technique where the system handles missing or invalid data by repeating its previous valid result, such as repeating the last temperature reading or maintaining the previously used screen color.

8
New cards

Substituting the Closest Legal Value

An error-handling technique where an out-of-range value is clamped to the nearest allowable boundary, such as substituting 0 when a string length is reported as less than 0.

9
New cards

Correctness

A software quality goal where a system never returns an inaccurate result, preferring to return no result at all rather than a wrong result; favored in safety-critical applications.

10
New cards

Robustness

A software quality goal where a system always attempts to keep operating even if it sometimes produces inaccurate results; favored in consumer applications.

11
New cards

Exceptions

A specialized mechanism by which a routine passes along errors or exceptional events to the calling code when it encounters an unexpected condition it cannot handle locally.

12
New cards

Level of Abstraction (in Exceptions)

The architectural guideline stating that thrown exceptions should match the conceptual layer of the routine (e.g., avoiding throwing an EOFException from an Employee.GetTaxId() method).

13
New cards

Empty Catch Block

A bad programming practice where an exception is caught but contains no handling or logging code, improperly ignoring errors that should not be overlooked.

14
New cards

Runtime AI Components

System dependencies such as LLM APIs, agentic tool-calling systems, classical ML models, and RL policies that introduce stochastic outputs, variability across runs, and non-deterministic behavior.

15
New cards

Out-of-Distribution (OOD)

A failure mode in classical machine learning and reinforcement learning where input data lies outside the model's training distribution, resulting in poor or unreliable predictions.

16
New cards

Core Defense Strategy for AI Components

A defensive approach that involves defining strict boundary preconditions and postconditions, rigorously validating both inputs and outputs, and degrading gracefully with clear fallbacks.

17
New cards

Practical Confidence Thresholds (for AI)

A operational decision model where high confidence leads to auto-applying results, medium confidence triggers a request for user confirmation, and low confidence initiates a fallback or human review.

18
New cards

Removal of Debugging Aids

The practice of using build tools (such as Gradle, Ant, or Make) or preprocessor conditionals (such as #if defined(DEBUG)) to exclude internal diagnostic code prior to deploying production software.