Skip to content

Latest commit

 

History

History
37 lines (20 loc) · 1.68 KB

File metadata and controls

37 lines (20 loc) · 1.68 KB

Mapper

Scenario

Foobar&Sons, vendor of Multigrate, a platform that aims to integrate CRM data from various vendors, wants to handle data transfer between a growing number of systems, starting with FirstSYS and SecondSYS.

Both systems Multigrate deals with, have customer data (person and address) but represented in a different way. Multigrate shall transfer customer data between the two platforms.

Choice of Pattern

In this scenario we want to apply the Mapper Pattern to provide an object that sets up a communication between two independent objects (Fowler).

Test

We have identified the customer as the object that exists in firstsys and secondsys but represented in a different way. To connect both sides we introduce the CustomerMapper.

Test

The CustomerMapper moves data from firstsys to secondsys and vice-versa.

Test

Here the mapping process (when to map) is triggered by the Session.

Try it out!

Open MapperTest.java to start playing with this pattern. By setting the log-level for this pattern to DEBUG in logback.xml you can watch the pattern working step by step.

Remarks

  • The pattern effectively limits dependencies. The CustomerMapper depends on details in firstsys and secondsys, none of them depends in any way on the mapper.

References

  • (Fowler) Fowler, M.: Patterns of Enterprise Application Architecture. Addison-Wesley (2002)