Reputation: 11483
They seems to be similar.
Upvotes: 8
Views: 6827
Reputation: 92
Active record pattern for persistance it's anti pattern for me, we have to seprate database access and treatement to another class for isolation, using the repository it's the best solution and simplified code source !
Upvotes: -1
Reputation: 14505
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/
Upvotes: 24