Skip to content
StackDecode
System Design
15. Software Design PatternsAnimated walkthrough

Data Mapper Pattern

Moves data between objects and the database.

The idea

The mapper keeps domain objects free from database knowledge.

Watch it work

The steps light up one at a time. Use the controls to pause or step through.

  1. 1Domain objects are plain
  2. 2The mapper loads and saves
  3. 3SQL stays in the mapper
  4. 4Tests need no database
1/4

Step by step

  1. 1Domain objects are plain
  2. 2The mapper loads and saves
  3. 3SQL stays in the mapper
  4. 4Tests need no database

Where it is used

ORMs like Hibernate.

Watch out for

Extra layer to maintain.

Related