3
votes

I am new to DDD and wants to clarify few doubts. Any help is appreciated.

  1. In DDD model the assembly reference hierarchy top down, which means Model can reference Infrastructure and should not be other way round. Now if we declare all our classes in Model assembly then in that case, the Infrastructure class will have to refer the Model Assembly for to get the class information for Concrete repository implementation in the data access layer (DAL). Also Model assembly will have to reference the Infrastructure Assembly to access the DAL layer. I am confused about this! What should be the right approach?

  2. Should we have the Repository and UnitOfWork interface in Model layer or Infrastructure DAL layer as in like have the interface in Model layer but the actual DAL implementation in Infrastructure layer?

  3. If we need other assembly which contains some generic utility functions or Classes (like custom CommandMessage class etc to communicate within Enterprise Service Bus architecture), where do we place all those things and what should be the preferred namespace (For example CompanyName.Model.Common)?

1

1 Answers

2
votes
  1. Model assembly should not refer Infrastructure Assembly. It's vice versa. Model assembly just declares required interfaces. You should refer your Model assembly from Infrastructure Assembly. And implement those interfaces. There could be many different assemblies with implementations of interfaces, required by model. Later you provide interfaces implementations via dependency injection.
  2. As stated above, repository and unit of work should be declared in Model assembly.
  3. Communicating within Enterprise Service Bus architecture seems to me like infrastructure task. I think it's not part of model.