They seems to be similar.
The Repository pattern. Repositories are classes or components that encapsulate the logic required to access data sources. They centralize common data access functionality, providing better maintainability and decoupling the infrastructure or technology used to access databases from the domain model layer.
Repository Pattern is an abstraction of the Data Access Layer. It hides the details of how exactly the data is saved or retrieved from the underlying data source. The details of how the data is stored and retrieved is in the respective repository.
A repository is a specialisation of the Facade pattern which is structural.
What is the repository pattern? The repository pattern is a software design pattern that decouples the data access logic from the business logic by introducing a centralized component called a repository.
They are different.
Active Record Pattern defines An object that wraps a row in a database table or view, encapsulates the data access, and adds domain logic on that data.
In the Repository pattern all of the data access is put in a separate class and is accessed via instance methods. To me, just doing this is beneficial, since data access is now encapsulated in a separate class, leaving the business object to get on with business. This should stop the unfortunate mixing of data access and business logic you tend to get with Active Record.
Check this link for understanding:
http://moleseyhill.com/blog/2009/07/13/active-record-verses-repository/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With