Skip to content

Commit a804e2d

Browse files
chore(docs): add faq to readme (#494)
1 parent 6158743 commit a804e2d

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
@@ -453,6 +453,35 @@ LithicClient client = LithicOkHttpClient.builder()
453453
.build();
454454
```
455455

456+
## FAQ
457+
458+
### Why don't you use plain `enum` classes?
459+
460+
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.
461+
462+
### Why do you represent fields using `JsonField<T>` instead of just plain `T`?
463+
464+
Using `JsonField<T>` enables a few features:
465+
466+
- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)
467+
- Lazily [validating the API response against the expected shape](#response-validation)
468+
- Representing absent vs explicitly null values
469+
470+
### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?
471+
472+
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.
473+
474+
### Why don't you use checked exceptions?
475+
476+
Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.
477+
478+
Checked exceptions:
479+
480+
- Are verbose to handle
481+
- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error
482+
- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)
483+
- Don't play well with lambdas (also due to the function coloring problem)
484+
456485
## Semantic versioning
457486

458487
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)