Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

Breaking the dependency rule

Open zkdzegede opened this issue 8 years ago • 1 comments

I keep seeing people do this in their clean architecture examples.

They put the mapper in the entity layer, pointing to a domain object. Doesn't this break the dependency rule?

Or am I missing where the entity -> use case -> presenter -> ui boundary is being implemented....

https://github.com/android10/Android-CleanArchitecture/blob/master/data/src/main/java/com/fernandocejas/android10/sample/data/entity/mapper/UserEntityDataMapper.java#L19

Dependency Rule: source code dependencies can only point inwards and nothing in an inner circle can know anything at all about something in an outer circle.

zkdzegede avatar Jan 20 '17 15:01 zkdzegede

I think you took the UserEntity class found in the data module literally as entity inside the domain layer. In the project you find three modules: data, presentation and domain. data knows about domain but not the other way around actually. Just refer to this image for it to be clear: https://8thlight.com/blog/assets/posts/2012-08-13-the-clean-architecture/CleanArchitecture-8b00a9d7e2543fa9ca76b81b05066629.jpg Data module is found in the outermost layer in that picture. So it actually is pointing inwards there's just a misunderstanding between the class name UserEntity and the Entities layer

arthlimchiu avatar Feb 23 '17 14:02 arthlimchiu