تنظيم الحزم داخل الوحدة
بنية المجلدات والحزم القابلة للتوسع
تنظيم الحزم داخل الوحدة درس مجاني في Kotlin Multiplatform Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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. 🎉
الأسئلة الشائعة
هل درس «تنظيم الحزم داخل الوحدة» مجاني؟
نعم — نص درس «تنظيم الحزم داخل الوحدة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Kotlin Multiplatform Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.
ماذا ستتعلم في «تنظيم الحزم داخل الوحدة»؟
بنية المجلدات والحزم القابلة للتوسع تتمرن على Kotlin Multiplatform Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Kotlin Multiplatform Academy؟
لا تُشترط خبرة سابقة. Kotlin Multiplatform Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «تنظيم الحزم داخل الوحدة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Kotlin Multiplatform Academy هذا؟
نعم. كل درس في Kotlin Multiplatform Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- تصميم API عامة صغيرة
- رؤية internal مقابل public
- تنظيم الحزم داخل الوحدة
- توثيق API للفريقين