Skip to content

Commit fd63219

Browse files
chore(docs): add faq to readme (#450)
1 parent e7312ce commit fd63219

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,35 @@ FinchClient client = FinchOkHttpClient.builder()
463463
.build();
464464
```
465465

466+
## FAQ
467+
468+
### Why don't you use plain `enum` classes?
469+
470+
Java `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.
471+
472+
### Why do you represent fields using `JsonField<T>` instead of just plain `T`?
473+
474+
Using `JsonField<T>` enables a few features:
475+
476+
- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)
477+
- Lazily [validating the API response against the expected shape](#response-validation)
478+
- Representing absent vs explicitly null values
479+
480+
### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?
481+
482+
It is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class.
483+
484+
### Why don't you use checked exceptions?
485+
486+
Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.
487+
488+
Checked exceptions:
489+
490+
- Are verbose to handle
491+
- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error
492+
- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)
493+
- Don't play well with lambdas (also due to the function coloring problem)
494+
466495
## Semantic versioning
467496

468497
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

0 commit comments

Comments
 (0)