In one of our projects we have some sort of code duplication which we would like to get rid of: It is about code for the same calculations on both DTO and model classes.
E.g. we have the following 2 methods:
boolean isFreeShipping(CartDto cartDto) {
...
}
boolean isFreeShipping(CartModel cartModel) {
...
}
What is the best approach to solve this?
- Have the calculation only for the model, and convert the DTO to the model if needed?
- Or vice versa?
- Introduce a specific value object which holds only the necessary fields and use this for the calculation - with mappers for both DTO and model?
Aucun commentaire:
Enregistrer un commentaire