Answer the question
In order to leave comments, you need to log in
What is the difference between active record and data mapper?
What is the difference between active record and data mapper ? Both, as I understand it, allow you to work with a record in the table through OOP, but what exactly are the differences and what are +/- ?
Answer the question
In order to leave comments, you need to log in
Both of these patterns are designed to transform data from a relational representation to an object representation. The difference is in how they do it and how they are organized, in short:
ActiveRecord is an object that stores data and contains logic for interacting with the database.
Advantages: simplicity, convenient to use on small projects.
Disadvantages: the pattern violates many principles, in particular the Single Responsibility Principle, its use usually makes the code highly coupled, which makes it impossible to use it on complex projects.
DataMapper - an object that stores the logic of interaction with the database. It does not store data like ActiveRecord
Benefits: allows you to build a loosely coupled architecture, separate applications into layers
You can read more details from Fowler, and you can just google it, a lot of materials have already been written on this topic on the Internet.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question