-
Notifications
You must be signed in to change notification settings - Fork 0
Home
A model is a business object, or a data access object, that may contain both data and logic, such as ORM objects. A DTO is an object that carries data between processes. As such, a DTO may contain information from more than one model object. Raven simplifies the mapping between business objects and DTOs using annotations.
There are a few ways in which software engineers can use DTOs:
- In some frameworks, model objects can be directly mapped to DTO objects. For example, Spring enables entities to JSON without requiring additional code.
- Use DTO factories to convert entities to DTOs and vice versa. In some cases, it is a usually a direct translation using getters and setters. Bean utilities can be used to save writing boiler-plate code.
Above methods work fine when the mapping is a simple one. In complex cases, additional logic has to be written. Occasionally, this can result in duplicate code and/or tedious property copying code. If using factories, it is a usual practice to have one factory per DTO, resulting in a large number of factory classes.
Raven grew out of a desire to simplify this mapping between DTOs and business objects and to reduce boiler-plate code for conversion.