Reputation: 6116
This is a Spring Boot API project. We currently have a 3 phase model design and I wanted to know if that is enterprise best practice. For example, if someone made a GET
call for all cars then the API would:
CarEntity
. This contains some db information like date added, updated date, etcCar
object. This strips off that extra db info.Car
object to the control to be sent to the client after converting to a CarDTO
object.So for 1 general type we have 3 objects: CarEntity
, Car
, CarDTO
. Is this the most efficient and best practice?
Upvotes: 0
Views: 334
Reputation: 409
It really depends on your requirements and design needs.
I design simple web applications and generally use the same object across all three layers (Persistence, Business and Web).
But in some cases you would need more than one class. For instance, if you expose a class for a remote client, it'd make sense to create a new class instead of reusing the persistence layer class.
In the EE world, they like to stress Separation of Concerns and SOLID pricipals. So, you could argue that multiple objects are most efficient and best practice in the long run. For my use, they are generally winded and clutter the project. In some cases, they are necessary.
Upvotes: 1