3 ms·
> Defensive programming is erroring out and refusing to do anything from that point forward (think of it like an uncaught exception with less information) I’m
by jsjohnst 9y ago
> Defensive programming is erroring out and refusing to do anything from that point forward (think of it like an uncaught exception with less information)
I’m not sure where you got that impression, but it’s not the generally accepted definition.
Defensive programming does not imply crash/abort/exit, it just simply implies a style of programming where you don’t trust “things will always be ok”. That could involve checking every input for correctness, checking every function output, handling all exceptions, etc. Yes, a defensive method could throw an exception on invalid input, but if the entire program is written defensively, then it should be handled and potentially continued.