Answer the question
In order to leave comments, you need to log in
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
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.
it would be correct to formulate the question as follows - how does ActiveRecord differ from DM
DM:
AR:
Registry:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question