Mapper Pattern

  1. Summary
    1. It is a generic base pattern that and can be though of more complex version of gateway.
    2. A mapper is an insulating layer between subsystems. It controls the details of the communication between them without either subsystem being aware of it. 
    3. A mapper often shuffles data from one layer to another.
    4. The complicated part of using a mapper is deciding how to invoke it, since it can't be directly invoked by either of the subsystems that it's mapping between. Sometimes a third subsystem drives the mapping and invokes the mapper as well.
    5.  How a mapper works depends on the kind of layers it's mapping. The most common case of a mapping layer that we run into is in a Data Mapper, so look there for more details on how a Mapper is used.

  2. Type of Mappers 
    1. As mapper is a very generic pattern so it can be use in several situations , some very common types are listed below.
      1. Data Mapper 
      2. Protocol Mappers 
      3. Schema Mappers 
      4. Interface Mappers (Adapters) 
  3. Related Patterns
    1. Data Mappers :One of the most used mapper patterns for mapping data source to business model.
    2. Protocol Mappers.
    3. Schema  Mappers
  4. Specific Considerations
    1. Gateway Vs Mappers
      1. Essentially a Mapper decouples different parts of a system. When you want to do this you have a choice between Mapper and Gateway.
      2. Gateway is by far the most common choice because it's much simpler to use a Gateway than a Mapper both in writing the code and in using it later.
    2. Mapper Vs  Mediator 
      1. Mapper is similar to Mediator [Gang of Four] in that it's used to separate different elements. 
      2. However, the objects that use a mediator are aware of it, even if they aren't aware of each other; the objects that a Mapper separates aren't even aware of the mapper.
  5. References 
    1. http://martinfowler.com/eaaCatalog/mapper.html