Hi @coder rock,
Please suggest me we are developing an mvc web application and which one is the best
First, the two patterns are not related; the factory pattern is a creation pattern, while the repository pattern is a structural pattern. Factories and repositories work well together.
In some cases you can delegate responsibility for object creation from your repository to your factory classes when you're reconstructing objects from the data store.
client <=> repository -> factory
|
v
database
- The client requests an object from the repository.
- The repository queries the database.
- The repository sends raw data to the factory.
- The factory returns object.
Depending on your situation, I personally think using repository pattern is enough.
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.