Which design pattern do you prefer, Active Record or Repository?

View other answers to this thread
Start a personal dev blog on your domain for free and grow your readership.

3.4K+ developers have started their personal blogs on Hashnode in the last one month.

Write in Markdown · Publish articles on custom domain · Gain readership on day zero · Automatic GitHub backup and more

Jorge Riva's photo

Why not both?

Entity e = Entity.create(new Repository()); -> or inject IRepository e.setSomeField("abc"); e.save(); -> inside _repository.Save();