Hexagonal Architecture

Despite both following facts, the IoC container can be applied to other architecture styles and the Hexagonal Architecture can be implemented without IoC, at the end, IoC and Hexagonal Architecture just work well together :).

This architecture helps to refine a model to separate the functional to the technical. The technical concern is pushed to the boundary of the model within contracts (i.e. interfaces), identified as ports. The contacts are implemented within the infrastructure by adapters

Port and adapter

Obviously, a port can be satisfied by many adapters. Therefore, it becomes easy to configure a setup by execution contexts: development, integration testing, functional testing, production ...

One port, many adapters

The relationship between two models can be handled with a regular Facade.

The model to model relationship

However, the relationship can be handled using the port/adapter approach. The introduction of a component which expose only the API of a model leads to definition of contextual adapters. For instance, the component API can be satisfied by an adapter dedicated for testing purpose which is just a mock of the core implementation.

Modularity of the model's Facade