Reputation: 177
Now I study about the Spring Boot that with JAVA platform.
A problem I faced is how can you tell the difference between DTO, VO, Entity, Domain, and Model.
Honestly it all look too similar to tell the difference.
I already checked some stackoverflow answers about "Difference between DTO and VO" and something like that.
However, I am still wondering how do they different each other in terms of developer with Spring Boot.
Upvotes: 15
Views: 34532
Reputation: 15318
double
value) and it's possible to compare Value Objects using these primitives. They don't have a database ID. They help replacing primitives with more object-oriented classes related to our particular domain.In order to get acquainted with these you should read:
Upvotes: 28
Reputation: 1756
DTO (Data Transfer Object):
Are containers which are used to transport data between layers and tiers.
When you're working with a remote interface, each call is expensive and the number of calls should be reduced. The solution is to create a Data Transfer Object that can hold all the data for the call. It needs to be serializable to go across the connection. Usually an assembler is used on the server side to transfer data between the DTO and any domain objects. It's often little more than a bunch of fields and the getters and setters for them.
Java enum
.
A Value Object's identity is based on their state rather than on their object identity and is immutable. A real world example would be Color.RED, Color.BLUE, SEX.FEMALE etc.
Domain Model:
Contains all Entities and Value Objects. And some other types of classes depending on the classification you use.
Model:
Defines a holder for model attributes and is primarily designed for adding attributes to the model.
ModelMap:
Is an extension of Model with the ability to store attributes in a map and chain method calls.
ModelAndView:
Is a holder for a model and a view; it allows to return both model and view in one return value.
Model, ModelMap, and ModelAndView are used to define a model in a Spring MVC application.
DAO (Data Access Object) or Repository:
A Data Access Object abstracts and encapsulates all access to the data source. The DAO manages the connection with the data source to obtain and store data.
The DAO implements the access mechanism required to work with the data source. The data source could be a persistent store like an RDBMS, or a business service accessed via REST or SOAP.
The DAO abstracts the underlying data access implementation for the Service objects to enable transparent access to the data source. The Service also delegates data load and store operations to the DAO.
Service:
A Service Layer
defines an application's boundary and its set of available operations from the perspective of interfacing client layers.
It encapsulates the application's business logic, controlling transactions and coordinating responses in the implementation of its operations.
Though Putting business logic here is an anti-pattern introduced around the times of EJB 1.x and 2.x. Preferably, you should put the business-related functionality into Domain Model. Read about Anemic vs Rich Model: Anemic architecture - enemy of testing
Before understanding the Spring Boot Architecture, you must know the different layers and classes present in it. There are four layers in Spring Boot are as follows:
Presentation Layer:
The presentation layer handles the HTTP requests, translates the JSON parameter to object, and authenticates the request and transfer it to the business layer. In short, it consists of views i.e., frontend part.
Business Layer:
The business layer handles all the business logic. It consists of service classes and uses services provided by data access layers. It also performs authorization and validation.
Persistence and Database Layer:
The persistence layer contains all the storage logic and translates business objects from and to database rows. This is also where CRUD (create, retrieve, update, delete) operations are performed.
Upvotes: 11
Reputation: 12505
These are just words, there is no general agreement over what they precisely mean.
They have different meanings in different projects, and part of onboarding a project is learning those project-specific definitions.
Also, the definitions of the words - overlap, since they were not invented "at one go", but rather traditionally used in influential books, blogs etc/
For example:
Takeaways:
Upvotes: 15