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

Why transform User in the User to UserModel in the presentation

Open Deep21 opened this issue 8 years ago • 6 comments

Hello everyone, Why we are transform the User class to UserModel, we could pass just the User instance afterall to the view. Why add this complexity ?

Thank you

Deep21 avatar Mar 21 '17 20:03 Deep21

The way I think about it is that User is a dto (data transfer object), should be a simple pojo, it will responsible for passing info back and forward between my app and an external service like a database or an api.

UserModel on the other hand will contain some presentation logic, manipulate the raw User data to be presentable and consumed by the View layer, lately I use bindings between this models and the views.

alexandru-calinoiu avatar Mar 22 '17 12:03 alexandru-calinoiu

it's for separating the modules for a testability perspective making the system decoupled, and as @android10 mentioned in his blog post

It is worth mentioning that each layer uses its own data model so this independence can be reached (you will see in code that a data mapper is needed in order to accomplish data transformation, a price to be paid if you do not want to cross the use of your models over the entire application).

mibrahimdev avatar Mar 23 '17 18:03 mibrahimdev

thank you

Deep21 avatar Mar 30 '17 18:03 Deep21

Thank you, great job.

2017-03-30 21:37 GMT+03:00 Deep21 [email protected]:

thank you

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/android10/Android-CleanArchitecture/issues/228#issuecomment-290504849, or mute the thread https://github.com/notifications/unsubscribe-auth/ALdsRH1DNrV-tSmVCIqb4pJoHmyJCnNLks5rq_Z0gaJpZM4MkXe5 .

zvvadim avatar Mar 31 '17 09:03 zvvadim

This question is also discussed here #72 and there are interesting comments.

lbensaad avatar Apr 15 '17 20:04 lbensaad

This can be closed

jemshit avatar Nov 09 '17 09:11 jemshit