Chandra Gopalaiah
Chandra Gopalaiah

Reputation: 13

Mapping Model in Presentation layer to object in Domain layer in Uncle Bob's architecture

Currently, I'm developing an Android application using Uncle Bob's clean architecture as part of learning Clean Architecture.

In one of the activity, I'm requesting the user to enter Name and DOB, I am determining age from DOB.

My question is in the presentation layer, I create a User Model class using Name and DOB and in my User object class in Domain layer has an extra field for Age which I can determine easily from DOB. Now should I perform the calculation of age in presentation layer when I'm converting the Model class(in the presentation) to Object class(in the domain) using mapper class which is in presentation layer or should I do that in the domain layer?

Since I'm using clean architecture for the first time so I want to make sure I follow the best practices to keep clean architecture scope intact in my application development.

Pardon me if you feel this is a silly question.

Highly appreciate your help and responses.

Upvotes: 0

Views: 687

Answers (1)

Daniel RL
Daniel RL

Reputation: 353

You should do it in the mapper class, since the presentation layer should not know details of the domain and the domain object should not have dependencies of the presentation object. It is better to make a mapper and manage all those kinds of transformations there.

Upvotes: 1

Related Questions