Module Interface Separation

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
To create client business applications using current Microsoft technologies, see patterns & practices' Prism.

Problem

You have a large smart client application that is composed of multiple modules written by different teams. Some modules have dependencies on other modules. For example, the accounts module requires the logging service in the infrastructure module. To access the logging service interface, the accounts module has an assembly reference to the infrastructure module assembly. Each time the implementation of the infrastructure module changes, the accounts module must be recompiled.

Figure 1 illustrates the dependencies between application modules.

Ff699260.efa2b9ef-4abd-4558-838e-95b092559031(en-us,PandP.10).png

Figure 1

Module dependencies

Solution

The problem is solved by breaking the module into two assemblies:

  • The interface assembly
  • The module implementation assembly

The interface assembly should contain public elements of the following types:

  • Service interfaces
  • Commands
  • Constants, including:
    • Command names
    • Event topic names
    • UI extension site names
    • Workspace names
  • Business entities (if they are passed between modules)

The module implementation assembly contains the implementation of your module. In this way, you can change the implementation of a module without requiring a recompilation of dependent modules. The dependent modules must be recompiled only when the interface assembly changes. Figure 2 illustrates the dependencies between modules and the interface assemblies.

Ff699260.a29db07b-a94b-443b-8450-add1fb3bf6df(en-us,PandP.10).png

Figure 2

Separation of interface and implementation for modules

Example

All modules in the Bank Branch Client reference implementation are designed by following this pattern. For an example of an interface assembly, see the Infrastructure.Interface assembly. The corresponding implementation assembly is the Infrastructure.Module assembly.