Kotlinのドキュメントを一通り読んだあとで「で、実際にこれらはどう使うのがいいのか」を知るために購入。
「Write unit tests」など、Not Kotlin-specific
のラベルが付いた章もそこそこあり、Kotlin固有じゃない部分は1/3-1/4ぐらいある。
それでも、 val
var
の使い分けから始まり、「Kotlinならこうできるよ」という期待通りの説明が数多くあり、満足度の高い本だった。
特にJava(JVM)との兼ね合いやKotlinの文化に関しては公式ドキュメントだけでは把握しきれないので非常に助かる。
個人的に良かったのは以下
- 「Eliminate platform types as soon as possible」
- Javaなど別の言語に由来してNull可能性が不明な型(Platform types)の取り扱いについて
- 「Prefer a nullable or Result result type when the lack of a result is possible」
- 例外・null・Resultの使い分け
- 「Consider factory functions instead of secondary constructors」
- ファクトリ関数の命名規則(文化)
- 「Consider defining a DSL for complex object creation」
- configuration-likeなDSLの定義方法
- 「Use sealed classes and interfaces to express restricted hierarchies」
- sealdedクラスの使い道
- 「Consider extracting non-essential parts of your API into extensions」
- 拡張関数の使い道
- 「Use the inline modifier for functions with parameters of functional types」
- inline修飾子の使い道
- 「Prefer Sequences for big collections with more than one processing step」
- Sequencesと他のコレクションの違い