Use cases
There are actually quite a few valid use cases to consider for runtime type checks.
For instance, when the service layer of our WorldExplorer application makes calls to the REST API, it will get the data back as JSON. Once we get hold of the corresponding JSON, we will need to extract information from it in order to create instances of our own domain model types. Doing so requires attention to avoid runtime type safety issues.
One problem with web APIs is that their implementation can change over time. At some point, some fields that we expect to be present might be renamed or even disappear. APIs should, of course, be versioned, but theory and reality don't always agree. In addition, we might also make spelling mistakes on our ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access