I have been studying and trying to implement the clean architecture in Android and have been working on a simple project to get some practice in.
The app simply shows popular movies, tv shows, and actors. The information that I would like to display about an actor must come from two separate calls to the API. My current design is a CharacterRepository that depends on Remote, Local, and Cache Datasources. In the other repositories for movies and tv shows, the NetworkDataSource simply delegates to a single operation of the related API service class.
What I'm asking is should the character data source expose two operations (getCharacters
, getCharacterDetails
) and leave the combination of data as a responsibility of the repository, or should it expose a single getCharacters
operation that merges the data from the 2 API calls into a single object?
From the official Guide to App Architecture
"The repository is the only class that depends on multiple other classes; in this example, the repository depends on a persistent data model and a remote backend data source."
If your data comes from multiple sources like local, remote & cache. They should be combined in the repository.
But, If you have 2 APIs one to fetch the list of characters & another one to get details of each character, they can be combined in the data source as both are the remote sources.