1
votes

Well according to Martin Fowler, the table/row data gateway aint mutually exclusive against data mapper pattern. This is what he said:

These patterns arent entirely mutually exclusive... Even if you are using Data Mapper as your primary persistence mechanism, however, you may use a data gateway to wrap tables or services that are being treated as external interfaces.

However, I cant think of a circumstances when data gateway is being used together with data mapper. Can anyone of you explain this with more details and possibly provide a real example of how integration of data gateway and mapper is done? Thanks.

1

1 Answers

0
votes

They aren't mutually exclusive in the sense that you may use both in a single project. Specifically, Fowler indicates that if you have certain tables that are treated as external interfaces, you may encapsulate them with a gateway. A table data gateway is a simple, direct interface. A data mapper on the other hand tends to provide better isolation then a table data gateway and as such is better suited for mapping to a domain model. A primary example of this approach is an ORM.