Osama Ibrahim
Osama Ibrahim

Reputation: 1021

MVVM repository in android

Am working on a huge android project that has more than 50 APIs request and using the MVVM pattern, My question is: can I add all the requests in the same app repository or I must create a repository for each service?

enter image description here

Upvotes: 1

Views: 598

Answers (2)

MRamzan
MRamzan

Reputation: 180

A good solution to this problem is, You must not implement all your API calling code to the same repository as it will become a massive single repository class. It will also be violating design principles i.e. rule of 30 as you are saying you have at least 50 APIs to work with. Also, it is not a good practice to modify a class, again and again, see Open Close Principle. You can make multiple API calling classes under the same package name.

Upvotes: 1

gts13
gts13

Reputation: 1094

As others suggested in the comments you should first define the modules of your app and then create the corresponding Repositories. This way you can easily maintain and test your application.

I strongly suggest you to have a look on this https://github.com/nickbutcher/plaid and mostly this video https://youtu.be/Sy6ZdgqrQp0

Upvotes: 2

Related Questions