buddysearch icon indicating copy to clipboard operation
buddysearch copied to clipboard

Domain layer component should not be used in Data layer component

Open narendrakothamire opened this issue 7 years ago • 7 comments

I have seen that you have used Domain layer components in Data layer as per clean architecture Data layer component should not be used in Data layer component

narendrakothamire avatar Feb 27 '17 05:02 narendrakothamire

@narendrakothamire Data layer resides one level above than Domain (that is core layer in clean architecture) so it's ok to use models and other classes from lower layer in above layer/s. Clean approach only says that you can't do reverse, for example : you can't use Data entities in Domain layer because it ruins boundaries.

mHerasimov avatar Mar 02 '17 12:03 mHerasimov

@MikeHerasimov You can't use Data entities in Domain layer because it ruins boundaries. Domain layer has used data entities as well. Presentation can have domain layer things and Domain can have data layer things but not reverse -As per my knlwg

narendrakothamire avatar Mar 02 '17 12:03 narendrakothamire

@narendrakothamire "Domain layer has used data entities as well." I'm not sure about this (first of all because @ihorvitruk uses mappers), can you provide some links?

Domain can't have data layer things because Data layer is above Domain. In clean architecture we have Domain <- Data <- Presentation (pointers show dependency)

As I said earlier Domain layer is our core layer.

mHerasimov avatar Mar 02 '17 13:03 mHerasimov

@narendrakothamire as far as I see you thought that Domain is our middle layer, it can be confusing at first because this layer has data from Data layer, but not directly.

In clean it is done by repository pattern.

I don't know where you started you Clean Architecture learning, you may want to take a look at some articles and repos in section 6 (I'm just too lazy to copy all of them) https://blog.aritraroy.in/what-my-2-years-of-android-development-have-taught-me-the-hard-way-52b495ba5c51#.w3idnlv2m

mHerasimov avatar Mar 02 '17 13:03 mHerasimov

I knw clean architecture very well U look this link from where this lib code has been taken https://github.com/android10/Android-CleanArchitecture

narendrakothamire avatar Mar 02 '17 15:03 narendrakothamire

I alredy saw this repo and all articles related to it. you know clean architecture very well but claim that "Domain can have data layer things" I've tried to help but I guess that you just trolling me

mHerasimov avatar Mar 02 '17 19:03 mHerasimov

@MikeHerasimov is right on this. Data layer is an implementation layer (of the repository interfaces in the Domain layer). This is the same pattern followed in the https://github.com/android10/Android-CleanArchitecture link provided by @narendrakothamire.

thomasdsouza avatar May 24 '17 05:05 thomasdsouza