Inversion of Control (Explained Non-Technically)
A simple concept, explained in simple terms.
Join the DZone community and get the full member experience.Join For Free
I will use how businesses evolve to provide an analogy for Inversion of Control.
Businesses don't set out on day one to be a Fortune 500 company. Typically, they start with you in your garage (maybe with a friend).Over time, your business grows and you hire people, assign clearer functional responsibilities, and start to scale up your business. Businesses have to do this, while also changing quickly to stay competitive.
Within software, we have moved from Waterfall to Agile. Waterfall can be considered your "set out to build a Fortune 500 company," day one approach. Agile, on the other hand, says to build only things of value and evolve your system over time. Also, Agile focuses on being quicker to react to change. Therefore, Agile is a lot closer to how businesses grow, evolve, and stay competitive.
Unfortunately, our software architectures have still stayed within a Waterfall top-down approach. Architects will produce technology stack diagrams that indicate how the architectural layers of the system work. The nature of these layers is always a bureaucratic control from the top layer to the bottom layer. This is very similar to large companies with many layers of management. So our software architectures force us to design the Fortune 500 company before developers even get to write the first line of code.
Inversion of Control is like empowering employees in a business. Rather than the manager dictating exactly how the employees will work, the manager trusts the employees to undertake the goals of the business. In other words, the employees are in control of how the work gets done. They will decide what help to get (Continuation Injection). They will decide what business resources they require (Dependency Injection). They may decide to escalate issues with the work (Continuation Injection). They may even decide another employee may be better suited to do the work (Thread Injection).
By empowering the employee, we have inverted the control. The employee is now in control of how the work gets done. This is similar to the Inversion of Control in software, wherein the developer is in control of how they write code. They are not restricted by bureaucratic top down architecture controls from their managers. This allows the developer to evolve the business's software quickly so it may grow and stay competitive.
Published at DZone with permission of Daniel Sagenschneider. See the original article here.
Opinions expressed by DZone contributors are their own.