4 ms·
I do too but I'm finding that a lot of the time there are so many untyped inputs to a system that the static typing doesn't buy you that much. There always seem
by cageface 14y ago
I do too but I'm finding that a lot of the time there are so many untyped inputs to a system that the static typing doesn't buy you that much. There always seems to be a ton of xml configuration data, incoming JSON from web services, databases with different type schemes etc.
- MaxGabriel 14y agoI don't know about other environments, but on iOS I just create a class that I store the e.g. JSON data in.
- alexatkeplar 14y agoAs soon as you receive an untyped input, make it conform to a typed data structure, and throw some kind of error if you can't. That way you catch any issues in your input data long before it bubbles through your app and causes a problem which is super-hard to track down. See e.g. DictShield for Python (https://github.com/j2labs/dictshield https://github.com/j2labs/dictshield), Jackson for JVM (http://jackson.codehaus.org/ http://jackson.codehaus.org/), Swiz for node.js (https://github.com/racker/node-swiz https://github.com/racker/node-swiz)...