2

Say I have a DDD application with three bounded contexts i.e. Sales, Production and Marketing.

Say I wanted to setup an administration facility. The admin facility would allow superusers' to change data in the tables that are used by: SalesRepository; ProductionRepository and MarketingRepository.

How would the Administration facility pull information from the database:

Option 1) It use the three repositories i.e. SalesRepository; ProductionRepository and MarketingRepository

Option 2) Administration would be treated as a bounded context in its own right and have its own repository. This could be a generic repository as the bounded context contains CRUD operations only i.e. there is no domain logic.

I am specifically asking if a simple Admin facility should be treated as a bounded context. I am not asking: "what is a bounded context?".

  • 1
    Possible duplicate of What, in reference to DDD, is a bounded context? – Robert Harvey Sep 1 '17 at 17:45
  • @Robert Harvey, thanks for the link. However, I have already read it. I understand what a bounded context is generally. I am asking if a simple Administration facility (CRUD only) should be treated as a bounded context in its own right. – w0051977 Sep 1 '17 at 17:53
  • 1
    Is it a business domain, in the same manner that the other business domains are identified? I would suggest that it is. If not a business domain, at least a defined process. It's not necessarily just CRUD; you could have methods like GrantAccess(). – Robert Harvey Sep 1 '17 at 18:45
  • 1
    No, it is part of each business domain i.e. an admin function is required in the sales domain; also in the Production domain; also in the marketing domain etc. – w0051977 Sep 1 '17 at 18:47
  • 1
    What is a code smell? If it satisfies your specific requirements, what does the odor have to do with it? The only criteria that are relevant to your application involve things like performance, maintainability, etc., not some vague notion of code smell. – Robert Harvey Sep 1 '17 at 19:01
0

From what I understood about your domain, you need to (create if it does not exist and) use an authorization bounded context (AuthBC) that will manage the access right to the other BCs.

If the administrators (users that have all the privileges/permissions in the system) need some new function that do not exist yet in the BCs, for example to postpone a sale, then that function will be added as usual but the access to it will be restricted to only the administrators (in fact you could restrict it to the users that have the privilege named CAN_POSTPONE_A_SALE but this depends on the internals of the AuthBC). This applies to the queries too, as they will be protected by the same AuthBC.

If you wonder how to integrate the AuthBC with the other BCs: you can do this in the Application layer, in the Application services; before executing the domain function, the service call an application service from the AuthBC and ask it if the current user can do some action identified for example by a string. Please note that this referencing to the AuthBC should not be done from an aggregate or in a domain service, only from an application service; in any domain layer you must have code that do checks specific to that domain only.

BCs=Bounded contexts

  • Thanks. So it would have its own repository? – w0051977 Sep 2 '17 at 7:45
  • Of course. You persist the access rights of every user and/or resource. – Constantin Galbenu Sep 2 '17 at 7:47
  • Every bounded context should have its own persistence. However, you seem to manifest a lot of interest to the repositories. The most important part is identifying the bounded contexts and not the repositories. – Constantin Galbenu Sep 2 '17 at 7:50
  • I guess a generic repository would be suitable here as there is no domain logic. – w0051977 Sep 2 '17 at 7:51
  • That's up to you. Try with a generic one then refactor to a specific one if you need. Try the simples thing that works first. – Constantin Galbenu Sep 2 '17 at 7:54

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.