Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain layer entities need to be parcelable #1

Closed
akshaybhange opened this issue Feb 28, 2020 · 4 comments
Closed

Domain layer entities need to be parcelable #1

akshaybhange opened this issue Feb 28, 2020 · 4 comments

Comments

@akshaybhange
Copy link

HI @antoniolg, great work. I wanted to know domain layer entities are needed to be parcelable in order to pass between activities/fragments. But when we declare them parcelable we will need to convert this module from "java-library" to android library or something. How to handle this case. You don't need that in this case but please help me solve this issue.

@antoniolg
Copy link
Owner

No, in that case, you need to create models in the presentation layer, and do conversions between layers using data mappers. Domain models shouldn't know anything about parcelables, or Room (in case you save it to a database), or Json (in case you parse it from the server)... All that needs to be transformed between layers.

@akshaybhange
Copy link
Author

@antoniolg thanks, I have entities at framework level for Server responses & models at domain level can I use any of it for my use in presentation layer or do I have to create new ones for presentation layer only? If you have any article on data mappers (the easy & correct way) please provide that too.

ardakazanci added a commit to ardakazanci/clean-architecture that referenced this issue Apr 26, 2020
@JulienHivert
Copy link

Hello ! :D
Let me reopen the topic, because I am currently in the middle of an architectural realignment of a big project (passed from hand to hand). Being in the same situation as @akshaybhange on my Parcelable data class. From what I understand from your exchanges it is that it is necessary (for parcelable objects) to map from the domain layer to presentation. I would like to enlarge the question: Do we have to map ALL the objects between domain and presentation? Is this a good practice?
Sincerely

@antoniolg
Copy link
Owner

I don't think it's strictly necessary, only when it's required. But if you do it, it's not bad either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants