Session

Stop Paranoid Defensive Programming: Trust Your Types

"Classic" defensive programming is noisy: if checks everywhere, cascading try/catch, null verified ten times over, a diffuse paranoia that bloats the code without ever making it truly reliable.

What if we stopped? Instead of defending against bad data, let's make bad data impossible to represent.

Two pillars:

The always-valid model: an object can only exist in a valid state. We parse at the boundaries, we build value objects that refuse to be born invalid, and the rest of the code has nothing left to check.
Advanced type systems (ADTs, sum types, Result, explicit states): expected failures live in the signatures, not in invisible exceptions. The type checker becomes your safety net, not your personal discipline.
The result: less defensive code, more confidence. The happy path becomes readable again, error paths become explicit, and robustness shifts from runtime to design.

These principles are not tied to a single language: they apply to any object-oriented language with an expressive type system. You'll leave with one simple conviction: the best line of defensive code is the one you no longer have to write.


What Attendees Will Take Away
Recognize and remove redundant defensive code
Design "always-valid" value objects that refuse to exist in an invalid state
Encode expected failures in the types (Result, ADTs) instead of invisible exceptions
Model a domain so that illegal states are impossible to construct
Apply these principles beyond a single language, across any typed OO ecosystem

Guillaume Saint-etienne

Senior Coder, Dev Advocate, Software & Team Architect

Toulouse, France

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top