Mathieu H.
Mathieu H.

Reputation: 880

Relevance of Clean Architecture Use Cases / Domain Layer

For few years I read articles about Android Architecture and Clean Architecture.

In the clean architecture, we usually have the 3 layers : Presentation (containing MVVM/MVP) - Domain (containing POJO and UseCases/Interactors) - Data (containing repositories implementation)

In Android projects there is often only 2 layers : the presentation layer containing the MVVM stuffs, and the Data layer with the repositories. The repositories are directly accessed from the ViewModel, and the data are processed in the ViewModel before passing them to the View.

So my question is : what would be the purpose of the UseCases/Interactors on Android ? Are they relevant or can they be completely integrated to Android's ViewModel ?

Upvotes: 1

Views: 929

Answers (1)

Rob Conklin
Rob Conklin

Reputation: 9446

It depends on how you view your android app. If the App is purely a view layer, then no, they are not particularly relevant. If you are using it as more than a view-layer, and instead is a client application, then you would do well build a whole new layered application and not skip the UseCases and models of a clean architecture.

When to do this is purely a judgement call. For apps that have only trivial logic, and are used mostly as a presentation engine, with all the relevant business logic server-side, then you can probably get away with a viewmodel. Many apps have as much or more complexity client-side than server-side, at which point you will want to design them in a way that the system scales and can be maintained.

If you find yourself wondering where your UseCases belong, then you have probably crossed that threshold, and should design it as its own application.

Upvotes: 1

Related Questions