Magento 2.x Differentiate Between Factory and Repository

FactoryRepository
1The factory pattern deals with how an object is createdThe repository pattern deals with creating a set of data access services, It is CRUD methods
2Factory Model having very limited dataRepository Model having all data
3For saving model, never recommended Factory For saving model, always recommended Repository
4If creating Objects and fill those objects with data need to use a FactoryIf creating objects and fill those objects with database data need to use a Repository

Leave a Reply

Your email address will not be published. Required fields are marked *