Company
Date Published
Author
Jens Neuse
Word count
1240
Language
English
Hacker News points
1

Summary

The text discusses the issue of exhaustive switch cases in API clients, which can prevent the client from being forward compatible. This problem highlights three hidden issues when designing APIs: breaking clients, preventing forward compatibility, and the potential for unexpected behavior due to incomplete handling of all possible cases. The solution is to avoid using exhaustive switch cases in API clients and instead use a default case that handles unknown cases without throwing an error. To prevent this issue, it's recommended to inform and educate API users about the problem, be more conservative when adding new enum values or interface implementations, introduce a new field with a new type instead of adding a new enum value or interface implementation, version the API, track API usage and clients to identify and communicate breaking changes, and use analytics to monitor schema usage.