Skip to content

Commit 4cbbc9f

Browse files
chore(docs): add faq to readme (#262)
1 parent cfe17a1 commit 4cbbc9f

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,35 @@ OrbClient client = OrbOkHttpClient.builder()
452452
.build();
453453
```
454454

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

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