Hi everyone. I wild about clean architecture, design patterns... I felt a long time ago that I need to design application in another way, found awesome article about Clean Architecture, but have just started to implement it.
I have one question about Data and Domain layer.
As I understand.
Use cases. Use cases are verbs used in application like GetUserWithAwesomeAvatarImage or something else. This layer is responsible for creating specific request to data layer, data layer support crud operations only, all application specific logic should be handled on domain layerThere is also one important rule that dependency arrow should only point from upper layer to lower but not vice versa, but in example provided by author there dependency pointing from Data to Domain. Maybe I am wrong, but I thought that it should point from Domain layer to Data.
For example create all repository stuff on data layer but domain layer will just consume repository from data layer, for example using dependency injection.
Please explain this.
The exact same question has already been answered here.
@Trikke really thank you for your explanation.
I feel the same like the guy that started that topic, I have read your explanation several time but still a little it confused . Can you please answer to my one question.
Why does model proposed by @android10 is better than described by @andrewjohnson90.
What are the benefits of such architecture ?
I would be very grateful for answer.
@andrewjohnson90 did not describe any model in that thread. He just literally asked the same question as you and had some confusions about the setup of the project vs the architectural ideas.
@Trikke
Thanks for answer.
All in all, I think I got an idea, I was confused as well as a lot of user developers, because of standard 3-layer architecture and approaches like MVC.
Let me describe how do I understand this.
In case of CleanArchitecture we have another model.
UseCase ring/layer is the core of our app, it should not be dependent on any specific implementation and operates only with interfaces and abstract classes. All dependencies should be injected using dependency injection tool like Dagger2. UseCase layer or being pointed by UseCase layer. For example Presenter points to UseCase to get use cases and respond to user actions (buttons, lists ...). In turn Use Case layer points to abstract repository in order to get required data. DataLayer is outer most ring of the architecture. GetGeoLocation and in this case Use Case layer points to Infrastructure layer (being discussed in adjacent issue topic) and ask it to get location data. UI, Database, Framework ... Am I right or I am still don't understand this approach ?
Thanks.

And just a side note, while nr 4 is possible, it would probably not be the best to follow this example repository if you would ever want to do that. This is because this is a minimal example, and the scope is just to create a correct Android App with Clean Architecture.
If you would create a Java ToDo app which would work on multiple Java platforms, the setup would be different in terms of project/gradle setup. But you would still recognise how it works because it would also be based on Clean Architecture.
@Trikke thank you a lot for you time and explanation, I think I got idea. I felt that app should be based on similar architecture some time ago when I didn't know about clean architecture, so I am so glad that there are a lot of people are interested in this. Please can leave any your contacts or sent me an email [email protected]
I have been migrating to clean architecture in my project it is quite complex for the last month, but really had to add new features rather than refactoring architecture, but I think I will end up soon.
And when I finish migration I will share all my experience.
Thanks again.
@Trikke hi, couldn't find right issue to ask question about connection of _Domain_ and _Data_. I have confusion about this case:
if i need _token_ to make api requests, and getting token has some logic:
1) Where does _getToken()_ resides, in Domain or Data? _getToken()_ retrieve _String_ from DB (not api). I feel like i have to put logic in UseCase and DB code in Repository
2) If _method_A_ in Repository (in _Data_ layer) needs _token_:
Similar question for cache manager. If i need to get something from cache or Api (which has logic), does that logic resides in UseCase ? Repository will only do CRUD for Api and DB
@jemshit you are asking a really good question. Such things like authentication, sessions cannot persist on only one layer they are exist on mostly all layers of an application. I had the similar question and it was discussed here https://github.com/android10/Android-CleanArchitecture/issues/151
Most helpful comment
And just a side note, while nr 4 is possible, it would probably not be the best to follow this example repository if you would ever want to do that. This is because this is a minimal example, and the scope is just to create a correct Android App with Clean Architecture.
If you would create a Java ToDo app which would work on multiple Java platforms, the setup would be different in terms of project/gradle setup. But you would still recognise how it works because it would also be based on Clean Architecture.