Search code examples
architecturelayered

Modules on the same layer in layered architecture


In theory in layered architecture you can have multiple modules on the same layer. Can this modules cross reference to each other? Is is possible technically, eg. using .NET?


Solution

  • It is certainly possible to do so, just be careful not to introduce any cyclic dependencies between modules. In general, modules at a given layer should only depend on other modules from the same layer or from the layers below it. Modules should not be aware of the layers above them.

    If you want to make this even stricter, then you can also limit dependencies to other modules from the same or other layers immediately below the current one.

    Keeping the exposed interface to a minimum, e.g. exposing only a core set of public interfaces, value objects, and exceptions is always a good idea. You can use the language's access control features (i.e. private/package/public) to limit visibility of module internals from spilling into other layers.