this post was submitted on 30 Jun 2024
282 points (94.9% liked)
Programmer Humor
19572 readers
1745 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It can, but especially during serialization Java sometimes adds null references to null values.
That's usually a mistake by the API designer and/or Java dev, but happens pretty often.
That’s the thing though, isn’t it? The devs on either side are entering into a contract (the API) that addresses this issue, even if by omission. Whoever breaks the contract must rightfully be ejected into the stratosphere.
That's exactly not the thing, because nobody broke the contract, they simply interpret it differently in details.
Having a null reference is perfectly valid json, as long as it's not explicitly prohibited. Null just says "nothing in here" and that's exactly what an omission also communicates.
The difference is just whether you treat implicit and explicit non-existence differently. And neither interpretation is wrong per contract.
I think we’re fully in agreement here: if the API doesn’t specify how to handle null values, that omission means they’re perfectly valid and expected.
Imagine a delivery company’s van exploding if somebody attempts to ship an empty box. That would be a very poorly built van.