Java – clean architecture: combined with interactors
I recently stumbled upon Uncle Bob's clean architecture. I'd like to know whether the interactors can execute other interactors
For example, so far, these are my interactors: getemptyalbums, getotheralbums Both have callbacks returned in the album list (ArrayList of the album model)
Do I allow an interactor named getallalbums to execute the first two interactors in its run block?
@Override public void run() { getEmptyAlbums.execute(); } void onEmptyAlbumsReceived(ArrayList<Album albums){ getOtherAlbums.execute; } void onOtherAlbumsReceived(ArrayList<Album albums){ mMainThread.post(new Runnable() { callback.onAlbumsReceived(albums); } });
Solution
I've been thinking about the same thing. After finding little about this problem, I came to the conclusion that "yes" may be the best choice
My reasoning is as follows:
>Single responsibility: if you can't aggregate use cases, no one can really take a single responsibility If there is no aggregation, it means that the domain logic will eventually appear in the presentation layer and cannot achieve its purpose. > Dry: use cases can be shared and should be in meaningful places
In order to maintain a single responsibility, I will consider limiting aggregate use cases to only those, that is, executing those use cases and making any final transformation
In view of the age of this problem, I am interested to know which method you adopted and the problems you encountered