3 ms·
I am a big fan of design by contract. (http://retromocha.com/obvious/ http://retromocha.com/obvious/) I don't trust user input in any form, including the databa
by programminggeek 12y ago
I am a big fan of design by contract. (http://retromocha.com/obvious/ http://retromocha.com/obvious/) I don't trust user input in any form, including the database.
So, while a system like TypeScript that checks types in the code is fantastic, it doesn't check types in the input, which is how a lot of problems happen in the first place.
Seriously, just import one legacy dataset into your system or have to work with some JSON api, and all of a sudden you can't trust that the data is valid, correctly typed, or even sane.
Doing proper validation of types and data integrity at any input point can save you a whole category of sadly common bugs. That includes data coming out of any data source you use, like a database.
Runtime type checking is another tool to make validated data a common, sane thing.