mardi 23 décembre 2014

Repository pattern and shared entities

I'm considering using the repository design pattern for data abstraction, I'm using Phalcon PHP framework and using the following structure:



ModelA
|- Entity
|- Entity1.php
|- Entity2.php
|- Entity3.php
|- Repository
|- RepositoryA.php
|- Service
|- ServiceA.php


Now if I had to use the same Entity2.php in another ModelB for instance, I would lose the most convenient use of the repository pattern, which is that I can change the data source for Entity2.php only by modifying RepositoryA.php, instead of worrying about who also might have used that entity. If I didn't allow for direct access to entities, I can't perform joins across multiple repositories.


What is the best approach to handle this issue?


Aucun commentaire:

Enregistrer un commentaire