Support Center & Knowledge base

DependencyInversion

In our fundamentals, you’ll find a package called DependencyInversion. Dependency inversion is the last principle in the SOLID principles. We apply this principle as a step towards decoupling, by focusing on the abstractions / interfaces to define our dependencies, we gain more flexibility in the software to what concrete implementation we give. In addition to this principle, the package also represents the concepts surrounding Inversion of control. What this last concept gives us is a way to control creation and lifecycle from the outside. Combined, we gain a lot of flexibility and enables us to make decisions at a higher level - we can also by the virtue of interfaces being used, apply cross-cutting concerns. This is a powerful tool that makes it easier to take decisions across types in a system.

With the dependencies defined as interfaces, we get added benefits when writing our specifications (automated tests). We can now provide fake versions, or so called mock objects - making it easier to test things in isolation, which is a core goal for unit tests typically.