Explain the purpose of a UseCase or Interactor layer

Tests your grasp of separation of concerns. A great answer defines a UseCase as a single, reusable business operation that sits between the ViewModel and Repository. It keeps other layers clean and focused.
What's really being asked
This question tests your understanding of Clean Architecture principles, specifically the role of the domain layer. The interviewer wants to see if you can articulate why putting business logic directly in a ViewModel or Repository becomes problematic in large, complex applications. They are looking for your ability to reason about code organization, reusability, and testability at an architectural level. It's a test of moving beyond a basic MVVM implementation.
The full answer
A strong answer explains four key points in order. First, define a UseCase (or Interactor) as a class that contains a single, specific piece of business logic. It should have one public method, often using an invoke operator override in Kotlin. Second, explain its position: it sits in the optional domain layer, between the UI layer (ViewModels) and the data layer (Repositories). Third, describe its function: a ViewModel calls a UseCase to perform an action. The UseCase, in turn, may fetch data from one or more Repositories, apply business rules (e.g., combining data, filtering, complex calculations), and return the result to the ViewModel. Fourth, highlight the main benefits: reusability (the same logic can be used by multiple ViewModels), testability (business logic can be unit-tested in isolation), and improved separation of concerns (ViewModels handle UI state, Repositories handle data sources, UseCases handle business rules).
The mistakes people make
A major red flag is describing UseCases as simple pass-throughs that just call a single repository method. This indicates the candidate doesn't understand their purpose and is just adding boilerplate. For example, a GetUserUseCase that only calls repository.getUser() adds no value. Another mistake is placing UI-related logic (like formatting strings for display) inside a UseCase. Business logic should be platform-agnostic. Finally, candidates who can't articulate why this layer is beneficial, beyond "it's good practice," show a lack of deep architectural understanding. They might say "it makes the code cleaner" without explaining how.
What usually comes next
Expect questions like: "When is a UseCase layer overkill? Give an example." (Answer: For simple CRUD apps where the ViewModel logic is just repository.getData()). Another follow-up could be: "How would you handle a UseCase that needs to combine data from two different Repositories?" (Answer: The UseCase's constructor would take both repositories as dependencies). A third is: "Should a UseCase be a suspend function or return a Flow?" (Answer: It depends on the data source and the need. A one-shot operation is a suspend function, while subscribing to continuous updates would use a Flow).
A concrete example
Imagine a feature that shows a user's "progress badge". The logic is: fetch the user's last 10 workout sessions from WorkoutRepository and their subscription status from UserRepository. If the user is a "premium" subscriber and has completed more than 5 sessions in the last 7 days, they get a "Committed" badge. This logic—combining data from two sources and applying rules—is perfect for a GetProgressBadgeUseCase. The ViewModel simply calls this UseCase and displays the resulting badge, without knowing the complex rules involved.
Interview question
A feature requires combining user subscription status and workout history from two different repositories. Where is the best place to implement this business logic according to Clean Architecture?
- a.In a new, higher-level Repository that aggregates data from the other two repositories.
- b.Directly in the ViewModel, which will call both repositories and combine their data.
- c.In a new UseCase that takes both repositories as dependencies to apply the combination logic.Correct
- d.In the UserRepository, making it responsible for fetching data from the WorkoutRepository as well.
Why? this is the answer
A UseCase is designed to contain a specific piece of business logic, often orchestrating data from multiple repositories. Placing this logic in the ViewModel (B) mixes UI and business concerns, while having repositories call each other (D) violates their single responsibility.
Just read this? Test yourself on what you have been reading.
Read the original → developer.android.com
- #android
- #architecture
- #mvvm
- #usecase
- #domain layer
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on android — each one lists the topics its interview covers.
See open roles