0

I am trying to implement Clean Architecture on my Android App with standard MVVM components.

Almost every example I have found deals with simple business logic, i.e. simple CRUD operations over data fetched from either backend or local database.

For those examples, it's pretty clear that Use Cases use Repositories, and Repositories do "the talking" with the backend if needed.

However, on more complex apps (like POS app) this solution results in huge, god repositories that are impossible to handle.

Another option I've tried was to pass an interface of Api service (Retrofit) to the use case and use calls directly in separated calls. But, in this case my DTO's ended in the domain layer.

What am I missing here? What is recommanded way where to make API calls?

5
  • 1
    "this solution results in huge, god repositories that are impossible to handle" - you don't have to have a single repository. You can organize remote calls around the use cases and build smaller, more focused repositories (so, repos with restricted responsibilities, rather then a huge general purpose CRUD repo); these can use the same mechanism/library under the hood. Commented Feb 11, 2021 at 21:11
  • “... on ... complex apps ... [C.A.] results in ... god repositories” why are you making this claim? What’s making you do this? Commented Feb 12, 2021 at 4:17
  • @candied_orange let's say I have an InvoiceRepository that handles all invoice related api/database calls. At the moment I have: createAndSubmit resubmit() cancel() cancelPartially () getByNumber() getAll () getAllUnsynced() deleteSingle() deleteAll() On top of that, invoice object is pretty big and submit logic has some legel requirements (what needs to be done if there is no or poor internet vs when there is normal connection). Commented Feb 17, 2021 at 13:44
  • Still don’t see what about CA is forcing that to be a god repository. Most suspicious thing you said was “all”. Commented Feb 17, 2021 at 15:36
  • Ok, can you give me a hint on how to avoid it? Should I have InvoiceCancelationRepositoty, InvoiceSubmitRepository, etc. instead? Commented Feb 18, 2021 at 9:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.