by Daphne Thompson, on Aug 31, 2018 1:55:00 PM
First let me explain what Inversion of Control is, and how it is used. Procedural or imperative code that executes from top to bottom is said to have a flow of control. It is obvious the order in which the statements will be performed. However, there are some drawbacks to only having your program perform in this way.
They take on the burden of handling when and how code should be executed. Web developers then can focus on the proper application behavior when events like mouseover, click, or http requests happen.
So, what now? If we apply our understanding of how this can be useful, there are more advanced ways of taking advantage of it. Not only can we structure programs using callback functions, but using modern ECMAScript allows us to make the code even clearer.
As programs grow, and the amount of code needed to deliver feature-rich applications expands, it becomes more important to manage how the code is structured. ES6 modules are necessary additions to a modern codebase and allow a developer to think more acutely on the task at hand. Writing code in a more loosely coupled fashion cannot only let the code to be less complicated but also allows for it to be reused in more places. Inversion of Control is the underlying foundation that allows much of this to happen.
For further material on Inversion of Control, let me refer you to Mattias P. Johansson and his excellent description.
Hopefully, this has been a helpful overview on what Inversion of Control is, how you may already be using it, and how you can use it to your advantage in future applications.