Android-cleanarchitecture: why every layer has it's own user model?

Created on 17 Jan 2018  路  2Comments  路  Source: android10/Android-CleanArchitecture

why every layer has it's own user model? if I need change user model, I must change the three.

Most helpful comment

There are a lot of reasons for this, such as separation of concern principle, make layers become more independent... but the most important reason to me is that this keep the model clean of bloat.
In this repository sample, the UserEntity, User and UserModel look almost identical so you may think that there is no point in creating more code for yourself.
But in a real life app, the model use in data layer, because of API or database structure, can contains more unnecessary fields that will never be used by your business, or the presentation model can contains some field or method only used in your activity to render that field like isSelect. If you only use the domain model, it will become a monster (literally) with tons of fields, method.

All 2 comments

There are a lot of reasons for this, such as separation of concern principle, make layers become more independent... but the most important reason to me is that this keep the model clean of bloat.
In this repository sample, the UserEntity, User and UserModel look almost identical so you may think that there is no point in creating more code for yourself.
But in a real life app, the model use in data layer, because of API or database structure, can contains more unnecessary fields that will never be used by your business, or the presentation model can contains some field or method only used in your activity to render that field like isSelect. If you only use the domain model, it will become a monster (literally) with tons of fields, method.

Thank you for your explanation. May be I need study deeply.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZherebtsovAlexandr picture ZherebtsovAlexandr  路  3Comments

connexion2000 picture connexion2000  路  3Comments

StuStirling picture StuStirling  路  3Comments

alexandr2levin picture alexandr2levin  路  5Comments

Cook1 picture Cook1  路  4Comments