I'm refactoring a website I build. It's a website for a travel agency. I'm thinking of implementing the repository pattern.
The travel agency has two divisions, that have their own website and target different groups of customers. The backend however is the same for both websites. They both access the same DB tables. Some tables simply have columns that identify what division the records are for.
Let's imagine I want to build a TripRepository, that will be able to return Trip objects. Do you feel it makes sense to create a Repository that takes the Division as a constructor argument? Such that all results will be only for that Division?
So in other words, in pseudo code:
class TripRepository
{
method constructor( Devision );
// this will then only return Trips for the Devision passed to the constructor
method findAllTrips( /* some other criteria */ );
}
I could very well have it as an optional constructor argument of course, and even have a setter to switch Devisions if need be... but in general is there something objectional with doing this?
Or should I just always pass the Devision criterium to all search methods?