difference between a repository and factory pattern

0 votes
asked Jul 9, 2009 by blankman

Can you please outline the differences between the Repository pattern and the Factory pattern?

2 Answers

0 votes
answered Jul 9, 2009 by jeff-sternal

The Factory pattern is for creating objects, while the Repository pattern describes a general method of encapsulating CRUD operations against a data source.

0 votes
answered Jul 9, 2009 by worthige

The repository pattern deals with creating a set of data access services, ie. CRUD methods. The factory pattern on the other hand deals with how an object is created. A factory class will have a method that returns a new instance of a class.

The two are independent of each other; however, you will often see the factory pattern used alongside with the repository pattern in order to create a new instance of a entity.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...