News for hackers. Stuff that matters.
Re:Write tests. Not too many. Mostly integration (2017) by mcharezinski on Friday February 01, 2019 @12:00AM (#19051723)
Could you replace/change your implementation bugs into types bugs?
Re:Write tests. Not too many. Mostly integration (2017) by josteink on Friday February 01, 2019 @05:53AM (#19053176)
If you are parsing known JSON schemas, defining them as types instead of generic dictionary lookups makes this a type-error, not a implementation error.

I can’t see why anyone would want not to do this.

Re:Write tests. Not too many. Mostly integration (2017) by jacobush on Friday February 01, 2019 @08:25AM (#19053873)
Genuine question - how would I do this in VB.net? Is is as painful as I imagine, with a lot of classes?
Re:Write tests. Not too many. Mostly integration (2017) by josteink on Friday February 01, 2019 @08:56AM (#19054060)
I don’t think that’s painful at all. Yes you define it as a root class, with dependent classes as needed. This is the contract. It needs to be defined somehow, and IMO this is as good a way as any.

From there on you just use JSON.NET to convert your JSON-string to an instance of the root type, literally one line of code.

And after that you get code-completion and type-inference and compile-time checking for all data-object access.

It’s an absolute no-brainer.

Re:Write tests. Not too many. Mostly integration (2017) by jacobush on Friday February 01, 2019 @09:19AM (#19054236)
Thanks! I need to look into that.