Ad

Why Use UseCases? Android Jetpack Is Not Mentioning UseCases In The Docs

Is it really necessary to use UseCases in my android Clean Architecture?

In the Android Jetpack documentation they are not mentioning it. They are accessing the repository directly from the ViewModels.

Isn't that a better option? Isn't the UseCase code not just making it unnecessarily more difficult to adjust the code?

Ad

Answer

If you want to strictly follow Uncle Bob's clean architecture then you should use UseCases.

They are accessing the repository directly from the ViewModels. Isn't that a better option?

It depends, greatly, the clean architecture makes testing super easy, also makes you think more architecturally before you implement things and makes you not to make compromises a.k.a. adjusting code, and it follows SOLID principles which are just great.

On the other hand, it's much harder to setup project and sometimes it feels like you are overengineering it

But after setting it up you will see improvement in maintainability and also scalability.

I think that it's great to know what clean architecture is and take what suits your needs.

This is great resource if you want to learn more about clean architecture https://caster.io/courses/android-clean-architecture and how it fits android.

Ad
source: stackoverflow.com
Ad