0Pricing
Kotlin Multiplatform Academy · درس

تقسيم التعليمات البرمجية المشتركة إلى وحدات

وسّع قاعدة التعليمات البرمجية باستخدام وحدات Gradle متخصصة.

تقسيم التعليمات البرمجية المشتركة إلى وحدات درس مجاني في Kotlin Multiplatform Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Kotlin Multiplatform Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

One Giant Module Hurts

A single huge shared module slows builds and blurs ownership. Splitting it into focused Gradle modules keeps the codebase fast and easy to reason about.

What a Module Buys You

Each module compiles on its own and can be cached. Touch one feature and Gradle rebuilds only that module, not the entire shared codebase.

Split by Layer or Feature

Two common cuts: by layer (core, data, domain) or by feature (orders, profile). Pick the seam that matches how your team actually works.

A Core Module

Shared utilities and base types live in a core module that everything can depend on. It depends on almost nothing, sitting at the bottom of the graph.

Declaring a Dependency

One module uses another by declaring it in build.gradle.kts. The feature module depends on core and domain, never the other way around.

commonMain.dependencies {
  implementation(project(":core"))
}

No Dependency Cycles

Modules must form a one-way graph. If A depends on B and B on A, Gradle refuses to build. Avoiding cycles keeps the structure honest.

api vs implementation

Use implementation to keep a dependency private to your module. Use api only when consumers genuinely need to see those transitive types.

Every Module Has Source Sets

Each KMP module gets its own commonMain, androidMain and iosMain. The split is structural, so platform code stays organised within every module.

Faster, Parallel Builds

Independent modules let Gradle compile in parallel and reuse caches across builds. More modules, drawn well, often means noticeably quicker feedback.

Clear Ownership

Module boundaries double as ownership lines. A team owns its feature module, sets its public surface, and changes it without stepping on others.

Do Not Over-Split

A module per file is chaos. Start coarse, split when a piece grows or many teams touch it. Let real pain, not theory, drive the next cut. 🙂

Quick Check

What rule must your module dependency graph obey?

Recap

You split shared code into focused modules, kept the dependency graph one-way, chose implementation over api, and let real needs guide each new split. 🎉

الأسئلة الشائعة

هل درس «تقسيم التعليمات البرمجية المشتركة إلى وحدات» مجاني؟

نعم — نص درس «تقسيم التعليمات البرمجية المشتركة إلى وحدات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Kotlin Multiplatform Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.

ماذا ستتعلم في «تقسيم التعليمات البرمجية المشتركة إلى وحدات»؟

وسّع قاعدة التعليمات البرمجية باستخدام وحدات Gradle متخصصة. تتمرن على Kotlin Multiplatform Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Kotlin Multiplatform Academy؟

لا تُشترط خبرة سابقة. Kotlin Multiplatform Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «تقسيم التعليمات البرمجية المشتركة إلى وحدات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Kotlin Multiplatform Academy هذا؟

نعم. كل درس في Kotlin Multiplatform Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. البنية متعددة الطبقات لـ KMP
  2. حالات الاستخدام وحدود النطاق
  3. تقسيم التعليمات البرمجية المشتركة إلى وحدات
  4. تحديد ما يبقى أصليًا
← العودة إلى Kotlin Multiplatform Academy