views:

20

answers:

1

There is DAL library that exposes dozen of repositories. One repository per entity. There is PersonRepository & PhotoRepository.

When I add a new method to repository and method deals with entity it's obvious where I have to put it. If I want CreatePerson I'll create PersonRepository::Create(...) or when I need to update photo I'll create PhotoRepository::Update

But when method deals with entity relations things come vapor sometimes. Shall I create PersonRepository::AssignPhoto(PersonId, PhotoId) or shall I create PhotoRepository::AssingToPerson(PhotoId, PersonId) for example?

If things are clear to me (I suppose that Person is more important entity than Photo so I'll create PersonRepository method), some developers don't find appropriate method and tend to create duplicates in PhotoRepository.

How do you minimize this issue?

May be you create both methods (PersonRepository::AssignPhoto & PhotoRepository::AssignToPerson) at the same time (one method delegates call to another where it's implemented)? Or shall we have strong repository methods naming convention in the team? Or may be I shall change approach to repository boundaries?

A: 

In a object oriented world, I'd have a Person object with a method AssignPhoto.

To handle object relation manipulations over the repositories feels like a procedural approach, at least to me.

Greets Flo

Florian Reischl
But how do you decide?
Andrew Florko