G
G
galithr2017-01-23 10:45:02
Design patterns
galithr, 2017-01-23 10:45:02

How is Repository pattern different from DataMapper?

I deal with patterns ... There is a DataMapper pattern that performs database queries and converts data into objects, there is a Repository pattern that seems to do the same thing (at least according to the materials that I looked at very similarly). What is the difference between these patterns?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2017-01-23
@galithr

These are two completely different patterns.
The DataMapper is what is traditionally incorrectly referred to as a model. Stupidly a bridge between a DB and object: to read the data from a DB and to write down in object, to save an object in a DB. Actually CRUD. A way to automate routine operations. It cannot be a model due to its initial limitations.
In other words, this is a universal code suitable for working with any objects. Database tool. All its methods are the same for any objects.
A repository is what is actually a model - a set of methods that implement the application's business logic. A method in a repository can include a dozen different database queries to get the set of data needed by the application, plus processing them.
Unlike the DM, the repository also contains unique methods that reflect the specific needs of a particular application module.

T
trevoga_su, 2017-01-23
@trevoga_su

it would be correct to formulate the question as follows - how does ActiveRecord differ from DM
DM:
AR:
Registry:
registry.gif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question