2 min read
Working with Inversion of Control in Netadmin Nine
Netadmin Content Creator : Apr 17, 2017 3:06:00 PM
In Netadmin Nine – our next generation of the software – we have introduced a common concept called Inversion of Control, IoC. In software development, IoC is a design principle in which developers can focus on the code they are producing, and its specific purpose, without intricate knowledge about the parts they are interacting with, as these parts are provided by a framework rather than controlled by the developers.
It’s sometimes humorously referred to as the Hollywood Principle: “Don’t call us, we’ll call you.” In Netadmin Nine this means you should not develop against the core implementation of the system, instead you develop towards an abstraction provided by us – a “contract” we guarantee to fulfill – and the system will provide the dependencies required by your code when the system executes your code.
The purpose of using IoC is to decouple the implementation, making it more modular, removing or at least reducing the dependencies between different parts, focusing each part on what it is specifically designed for, preventing side effects when replacing or refactoring a part of the system, and to increase testability and extensibility.
In essence it allows us - and furthermore our partners - to view the core of Netadmin Nine more as a framework, and less as a set of libraries with a set of methods. This will let us work even faster and develop new features more rapidly.
Although new in Netadmin Nine the concept itself is a well-defined design principle, which may be applied through a number of various techniques. The specific technique used in Netadmin Nine is constructor Dependency Injection, DI. It allows you to declaratively express the dependencies in the constructor of a class and to use those dependencies throughout your code without knowing the implementation of the dependency, or how it will be fulfilled.
The use of Inversion of Control has become wide-spread across Netadmin Nine, from the user interface and our business layer down to pre-Nine extension frameworks such as Netadmin Assemblies. There are however, and will remain, low-level implementations which will not make use of IoC such as the pre-Nine Netadmin Objects database abstraction layer. That being said a lot of Netadmin Objects has been abstracted through interfaces and may be managed through the new interface IObjectManager, allowing the use of Netadmin Objects to be injected as a dependency.
When should you use IoC when developing for Netadmin Nine? Always, as long as it’s possible – that is how we use it ourselves. The less coupling made towards the core implementation, the less risk we have of core changes breaking the code – ours and yours. And it will increase the testability of the code!
At Netadmin, we are constantly working to improve and to take the software to another level. The abstractions (interfaces) used to achieve Dependency Injection are a work-in-progress, as this evolvement continues.