Crinsane
183
12
General

Should a repo only work with it's own 'entity'

Posted 5 years ago by Crinsane

Today I was working on an app and I stumbled upon something that made me wonder. What is the best practice in this one:

Say I have two entities Project and Task. Both of those entities have a corresponding repository. Now you want to add a method to the ProjectRepository to mark a project as complete. Marking a project complete will also mean all tasks of the project have to be marked as complete. Do you do this in the same repository? Does a ProjectRepository do TaskRepository stuff? Or do you call one repository from the other?

Other example could be creating a new Project and also add a few Tasks.

Of course there's no real right or wrong I think, just wondering what you guys think.

Please sign in or create an account to participate in this conversation.