Skip to content

Commit f92bf99

Browse files
chore(docs): add faq to readme (#240)
1 parent f35de10 commit f92bf99

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
@@ -617,6 +617,35 @@ OpenAIClient client = OpenAIOkHttpClient.builder()
617617
.build();
618618
```
619619

620+
## FAQ
621+
622+
### Why don't you use plain `enum` classes?
623+
624+
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.
625+
626+
### Why do you represent fields using `JsonField<T>` instead of just plain `T`?
627+
628+
Using `JsonField<T>` enables a few features:
629+
630+
- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)
631+
- Lazily [validating the API response against the expected shape](#response-validation)
632+
- Representing absent vs explicitly null values
633+
634+
### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?
635+
636+
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.
637+
638+
### Why don't you use checked exceptions?
639+
640+
Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.
641+
642+
Checked exceptions:
643+
644+
- Are verbose to handle
645+
- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error
646+
- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)
647+
- Don't play well with lambdas (also due to the function coloring problem)
648+
620649
## Semantic versioning
621650

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