We currently handle a well separated monolithic service which handles various 'contexts' to help with the separation. I haven't had any issues so far when dealing with problems that require the creation of a new context since it was simple enough.

Now I'm dealing with a group of entities (3, to be exact) that relate to each other and I'm not sure how to properly organize one of them in the project.

For the example we'll name them Branch, BranchService, Service.

Branch lives in its own context as does Service, but at the moment I am not sure where to place BranchService. In this case, BranchService is not just an entity to handle many-to-many, it has some information on it's own that is used around the service.

Since they are relatively coupled, should they be together and share the same context? Or is there an alternative for this case?

  • Ruby on Rails calls this concept a "Many to Many through..." relationship. The concept was to distinguish the fact that the relationship was it's own entity, but it still handled that many-to-many function. So for organization purposes, I might recommend treating it like a Many to Many and for application purposes treat it like it's own entity. Feb 21 '20 at 19:25

I am assuming by Context you mean these are vertical entities and they are logically separated (by assembly boundary or a dependency checker)?

With the limited information I have, can the services be layered? Can BranchService be a parent of Branch and Service and have a domain that concerns the relationships between the two?

Like, you are managing auto repair stores which have different kinds of oil change machines. So you model the stores and the oil change machines and they have their own operations and are directly accessible. You also have a service locator service with reference to the oil change machine service and stores services which can do tasks like finding the nearest location where we can fit another size large oil change machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.