Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Repository pattern as same as Active Record pattern?

They seems to be similar.

like image 658
Afshar Mohebi Avatar asked Aug 15 '10 09:08

Afshar Mohebi


People also ask

What is meant by repository pattern?

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.

Is repository an Antipattern?

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.

What type of design pattern is repository?

A repository is a specialisation of the Facade pattern which is structural.

What is repository pattern in flutter?

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.


1 Answers

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/

like image 190
YoK Avatar answered Sep 22 '22 00:09

YoK