How to get reference of the domain type from other Module (Asssembly) via loosely coupled way?

Topics: Prism v4 - WPF 4
Mar 21, 2013 at 12:07 PM
I am doing a design using PRISM framework and Domain-Driven design pattern. I have a question regarding the domain type reference between different Modules.

I have a Module (Assembly) called Order, another Module (Assembly) called Product. In the Model and ViewModel of the Order Module, we will use Product Class (Type) from Product Module.
How can I reference the Product type with loosely-coupled way.

I am thinking to do this by two ways:
  1. Define all the domain types in the Infrastructure Assembly, which will be referenced by all the Modules
  2. Define the interfaces in Infrastructure Assembly, and the domain types in the Modules will implement the according interface (Like Product will implement IProduct).
But I think these two solutions are not good. I hope I can get help from your guys here.

Thanks a lot.

Mar 21, 2013 at 4:54 PM
Could you elaborate on why you don't think these are good solutions?

The problem you describe is independent from Prism.
You will have to reference another .NET assembly to use a type in a, dependent, assembly.
There is no loosely-coupled way to do this AFAIK.

Additionally separating the interface from the implementation is a good thing.

Mar 21, 2013 at 5:07 PM

Based on my understanding, and taking into account the context of your scenario, the best option for this case would be to define those domain types in a Shared Assembly (Option 1), so they can be referenced by the rest of your Modules that use them.

As far as I know, the second option you are mentioning is more commonly used to share a Service between Modules in a loosely coupled way, but not for sharing types. That's why it doesn't seem to provide a benefit in your application context.

Hope this helps,

Federico Martinez
Mar 21, 2013 at 9:49 PM
Thanks Janverley and Fmartinez's reply.

Probably I will take the option 1, and use option 2 to share the services between Modules.