Modularisation

Architecture and dependency injection Senior Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Pick the fix

:feature:checkout imports classes from :feature:cart, and every cart change rebuilds checkout. Best fix?

Options
Hint 1 of 1

What should features depend on?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Move the shared contract into a :core or :feature:cart:api module both depend on

Correct. Features depend on a small API, not on each other's internals.

Why not the others?
  • B Merge the two features into one module. Undoes the modularisation.
  • C Copy the cart classes into checkout. Duplicates code and lets them drift.
  • D Turn on Gradle's configuration cache. Good for builds generally, but the dependency is the issue.

30-second answer

Modules give faster incremental builds (only changed modules recompile), enforced boundaries (internal and explicit dependencies), parallel work across teams and reusable pieces. A common structure is :app, :feature:* modules for screens, :core:* modules for data, design system and utilities, and optional API/implementation splits so features don't depend on each other's internals.

Practise saying it · 35 s. No recording, just a timer

Explain modularisation.

Say your answer out loud, then check which of these points you covered:

  • Faster builds and boundaries
  • app, feature and core modules
  • Features don't depend on each other
  • Convention plugins

Deep dive

Feature modules shouldn't depend on other feature modules; navigate through routes defined in a shared module.

Convention plugins in build-logic keep Gradle setup consistent.

Too many tiny modules slow configuration; start with clear boundaries, not maximum splitting.

Dynamic feature modules can be downloaded on demand with Play Feature Delivery.

Common mistakes

  • Feature modules depending directly on each other.
  • Splitting into dozens of modules before the boundaries are clear.
  • Copying Gradle config into every module.

Senior take & follow-ups

Lead with the benefits you measured, like build times, and the dependency rules.

Follow-up questions

Think of your answer first, then open the hint.

  1. How do features navigate to each other without depending on each other?

    Show hint

    Through route types in a shared navigation or api module.

  2. What are convention plugins?

    Show hint

    Shared Gradle plugins that apply common configuration to modules.

Compare on iOS: Modularizing a growing app Swift packages play the role of Gradle modules.

Suggest a fix if something here is wrong or out of date.