What is Inversion of Control in Programming? - Montana Webmaster

What is Inversion of Control in Programming?

Releasing Control is Hard to Do

In business school, we learned that entrepreneurs often destroy their own businesses because they are idea people, but are lousy day-to-day operations managers. They need Inversion of Control to manage their operations. This is called delegation in business management.

Drivers

There are some steps that often come before resorting to total Inversion of Control. For example, a single owner business has total control, but the owner may delegate bookkeeping or janitorial functions to a contracted service. This is like connecting your program to driver software that runs a printer. Your software doesn’t need to know about all the printers, it just calls a driver. The business owner might not know all the employees who for the janitorial service; the owner may not know what equipment is used to clean the office; the owner just knows that the office is clean.

Libraries

A business owner may hire someone to answer the phones and do other office tasks. Hopefully the front desk person understands how to do those tasks efficiently so the owner can rely on them with some minor training. This is like using a software library. A library contains pre-written code that performs specific functions, relieving the programmer from having to write code for common tasks. The programmer adds the library into the files and then calls the functions, as needed. The library is now part of the software, just like the front desk person is part of the company.

Dependency Injection

Dependency Injection for software development is like the shoe department used to be at some JCPenney stores. JCPenney didn’t own the shoes. JCPenney doesn’t even hire the shoe sales staff. It was a like a separate store running inside JCPenney store. A dependency injection platform is like that store. It runs certain functions of a program without being part of the actual program.

Resources

  1. Wikipedia on Inversion of Control
  2. Delegation – read this

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.