android10 / Android-CleanArchitecture

This is a sample app that is part of a series of blog posts I have written about how to architect an android application using Uncle Bob's clean architecture approach.
Apache License 2.0
15.49k stars 3.32k forks source link

Breaking the dependency rule #212

Open zkdzegede opened 7 years ago

zkdzegede commented 7 years ago

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.
arthlimchiu commented 7 years ago

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