Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.
Ramindur Singh edited this page Apr 18, 2018 · 5 revisions

Raven - A DTO/Model Mapping Utility

What is a DTO/Model Mapper?

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.

Why is a Mapper required?

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.