Data Mapper vs Data Access Object. Difference. Which one is better?

Possible duplicate:
Differences ORM / DAO / DataMapper / ActiveRecord / TableGateway?

Can someone help me understand the difference between data patterns and data access patterns? I already know about the data card template from the zandstra book. But when I looked for the data access object, I found out that there are very similar or even the same patterns. I also want to know which one should I use when writing my own framework (I'm trying to implement my own mvc php infrastructure to find out how modern frameworks work).

+6
source share
1 answer

The data mapper saves data from (and restores) the domain object , and the data access object will be used as an intermediary for the exchange of information between the domain object and the storage abstraction.

<update> The main difference between the two approaches is that the temporary data display element controls the domain object, while the data access object either receives the data indirectly (through some higher-level abstraction, for example, Service), or is controlled (and in some implementations, even instantiated) by domain object. </update>

None of the templates are remotely linked to an active (anti) template record that combines domain logic and storage abstraction in one instance, a href = "http://en.wikipedia.org/wiki/Single_responsibility_principle" rel = "nofollow"> SRP

And not one of the mentioned templates is bound to ORM. Some ORMs try to use the above template for implementation, but usually they do a pretty bad job.

Most of what you call “modern frameworks” use an active recording template and name instances of its “models”, which greatly simplify the concept immortalized by Rails.

+6
source

Source: https://habr.com/ru/post/924582/


All Articles