Clean Architecture & Use Cases Interview Questions

ARCHITECTURE › Patterns

What is Clean Architecture, and how is it usually applied on Android?

What a strong answer covers: It separates code into layers with dependencies pointing inwards: presentation (UI and ViewModels), domain (business rules, use cases, models) and data (repositories, network, database). The domain layer doesn't depend on Android or the data layer; the data layer implements interfaces the domain defines. Google's guide makes the domain layer optional, with UI and data layers required.

What is a use case or interactor, and when is it worth adding one?

What a strong answer covers: A use case is a class encapsulating one piece of business logic, like GetUserFeedUseCase or PlaceOrderUseCase, usually with a single operator fun invoke. It's worth it when logic is reused by several ViewModels, combines several repositories, or is complex enough to test separately. A use case that just forwards one repository call adds nothing.

What is the Dependency Inversion Principle, and how does it show up in a repository interface?

What a strong answer covers: High-level modules shouldn't depend on low-level details; both should depend on abstractions. The domain or ViewModel depends on a UserRepository interface; the data layer provides UserRepositoryImpl using Retrofit and Room. That lets you swap implementations, use a fake in tests, and keep the domain free of framework code. DI (Hilt) binds the interface to the implementation.

How do you apply Clean Architecture on Android, what goes in each layer, and when is it overkill?

What a strong answer covers: UI layer: composables, ViewModels and UI state models. Domain: use cases and domain models, pure Kotlin. Data: repositories, data sources, DTOs, entities and mappers. It's overkill for small apps or simple CRUD screens, where three sets of models and mappers for every entity triple the boilerplate. A strong answer applies it pragmatically: introduce a domain layer where logic actually lives and avoid mapping layers that add nothing.

Should the domain layer have its own models separate from network DTOs and database entities? Argue both sides.

What a strong answer covers: For: the API and database schemas change for their own reasons, and separate models stop those changes leaking into business logic and UI; DTOs can be nullable and messy while domain models are validated; entities can have database-specific shapes. Against: mapping code for every type, more classes, and little benefit if all three are identical. A balanced answer separates at boundaries that actually change independently, often keeping DTOs separate from the rest.

Back to Clean Architecture & Use Cases