The Daily WTF
A charitable description of Java is that it’s a strict language, at least in terms of how it expects you to interact with types and definitions. That strictness can create conflict when you’re interacting with less strict systems, like JSON data.
Tessie produces data as a JSON API that wraps around sensing devices which report a numerical value. These sensors, as far as we care for this example, come in two flavors: ones that report a maximum recorded value, and ones which don’t. Something like:
{ dataNoMax: [ {name: “sensor1”, value: 20, max: 0} ] dataWithMax: [ {name: “sensor2”, value: 25, max: 50 } ] }
By convention, the API would report max: 0 for all the devices which didn’t have a max.
With that in mind, they designed their POJOs like this:
class Data { String name; int value; int max; } class Readings
To read the full article click on the 'post' link at the top.