Re:From zero to 10M lines of Kotlin
by acchow on Tuesday October 25, 2022 @02:19PM
(#33334271)
I believe the standard practice (as popularized by Google) is that all fields are optional. This allows you to deprecate fields in the future while still support older (non-updated) clients.
[ Parent
| on HN ]
Yeah, my question is more about what you do as a consumer. How do you get back null safety if every field in the response is optional? Even moreso, in a SOA situation where 90% of what you work with comes across a HTTP boundary.
I'm not sure I understand the question. If you have only Optionals and Null does not exist, a NPE is impossible. The Optional type forces you to handle the empty case, so null safety is enforced by the type system.
The question is how do you handle the empty case for the hundreds of fields you pull from other systems.