开发者

DAL: repository boundaries question

开发者 https://www.devze.com 2023-01-09 05:17 出处:网络
There is DAL library that exposes dozen of repositories. One repository per entity. There is PersonRepository & PhotoRepository.

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 tea开发者_StackOverflow社区m? Or may be I shall change approach to repository boundaries?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消