DEV Community

Discussion on: Is “Defensive Programming” actually healthy?

Collapse
 
imtollu profile image
Ilja Tollü • Edited

That's not a defensive programming. That's just a common sense. Traffic lights are not equal. Green allows some dangerous action. Red is safe. So, it is just correct to explicitly check conditions to allow something dangerous and then fallback to less dangerous cases. Some code that would communicate this semantics would make a great job for its readers.