小さなPublic APIを設計する
公開するものと内部にとどめるものを決めます
「小さなPublic APIを設計する」はCoddyKit上の無料Kotlin Multiplatform Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはKotlin Multiplatform Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
What a Public API Is
Your module's public API is the set of functions and types other code is allowed to call. It is the front door both apps walk through.
Small Surface Wins
A small surface area means fewer things to learn and fewer things to break. Expose only what callers truly need, nothing more. 🎯
Start From the Use Case
Design backwards: write the call site you wish you had first. Let that ideal usage shape what your public functions look like.
// Imagine this is how both apps will call you
val text = greeter.greet("Maya")Expose Intent, Hide Steps
A good API shows the intent and hides the steps. Callers say what they want, not how the work gets done inside.
Name Things Clearly
Clear names are half your API. A method called priceWithTax tells the whole story without any extra docs to read.
fun priceWithTax(base: Double, rate: Double): Double {
return base + base * rate
}Prefer Simple Inputs
Take plain, obvious inputs like strings and numbers. Simple parameters make your API easy to call from both Android and iOS.
Return Useful Types
Return shared data classes instead of loose values. A typed result is self-describing and far harder to misuse.
data class Quote(val total: Double, val currency: String)Hide the Helpers
Internal helpers and rough edges should stay private. Only the entry points a caller actually uses belong in the public API.
Easy to Add, Hard to Remove
Every public thing is a promise. It is easy to add new API later, but removing it can break callers, so expose less up front.
Stay Platform-Neutral
Keep the API platform-neutral. If a signature mentions Android or iOS types, it cannot serve both apps from shared code.
Design for the Reader
The best APIs read like a sentence at the call site. Optimize for the caller, not for whoever wrote the implementation.
Quick Check
Let's test your API design instincts.
Recap
A great public API is small, clearly named, and shaped by real use cases. Expose intent, hide steps, and both teams will love it. 🎉
よくある質問
「小さなPublic APIを設計する」レッスンは無料ですか?
はい。「小さなPublic APIを設計する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Kotlin Multiplatform Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
「小さなPublic APIを設計する」で何を学びますか?
公開するものと内部にとどめるものを決めます ブラウザで直接実行するハンズオンコードでKotlin Multiplatform Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Kotlin Multiplatform Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのKotlin Multiplatform Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「小さなPublic APIを設計する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このKotlin Multiplatform Academyレッスンでコードを書いて実行できますか?
はい。すべてのKotlin Multiplatform Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 小さなPublic APIを設計する
- internalとpublicのVisibility
- モジュール内のPackageを整理する
- 両チーム向けにAPIをドキュメント化する