why every layer has it's own user model? if I need change user model, I must change the three.
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.
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,UserandUserModellook 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.