モジュール内のPackageを整理する
拡張しやすいフォルダーとパッケージ構成を学びます
「モジュール内のPackageを整理する」はCoddyKit上の無料Kotlin Multiplatform Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはKotlin Multiplatform Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Packages Are Folders With Names
A package groups related Kotlin files under a dotted name. Good packages make a growing shared module easy to navigate. 📁
Declare the Package
Every file starts with a package line. It should mirror the folder path so the structure stays predictable for everyone.
package com.acme.shared.domainGroup by Feature
Prefer grouping by feature over grouping by type. A cart package keeps its model, logic, and helpers together in one place.
Separate Domain and Data
A clean split is domain for pure models and rules, and data for networking and storage. The boundary keeps each part focused.
// com.acme.shared.domain -> models, rules
// com.acme.shared.data -> api, dbUse a Reverse-Domain Root
Start packages with a reverse-domain name like com.acme.shared. It keeps your code from clashing with library packages.
Mirror Folders to Packages
Keep the folder tree matching the package names. When they line up, anyone can find a class just from its full name.
A Tidy Public Package
Put the types you expose in one obvious public package, like com.acme.shared.api. Callers then have a single place to look.
Tuck Internals Away
Keep helpers in an internal package such as .impl or .util. The name signals at a glance that callers should stay out.
Shallow Beats Deep
Avoid endless nesting. A shallow tree of a few clear packages is easier to scan than ten layers of tiny folders.
Same Layout Across Source Sets
Use the same package layout in commonMain, androidMain, and iosMain. Matching paths make expect and actual pairs easy to spot.
Names Tell a Story
Read your package list top to bottom. The names alone should explain what the module does and where each concern lives.
Quick Check
Let's check how to structure packages.
Recap
Group by feature or layer, mirror folders to packages, keep it shallow, and hide internals. A clear tree scales as the module grows. 🎉
よくある質問
「モジュール内のPackageを整理する」レッスンは無料ですか?
はい。「モジュール内のPackageを整理する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Kotlin Multiplatform Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。
「モジュール内のPackageを整理する」で何を学びますか?
拡張しやすいフォルダーとパッケージ構成を学びます ブラウザで直接実行するハンズオンコードでKotlin Multiplatform Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Kotlin Multiplatform Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのKotlin Multiplatform Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「モジュール内のPackageを整理する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このKotlin Multiplatform Academyレッスンでコードを書いて実行できますか?
はい。すべてのKotlin Multiplatform Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 小さなPublic APIを設計する
- internalとpublicのVisibility
- モジュール内のPackageを整理する
- 両チーム向けにAPIをドキュメント化する