Inversion of control

In software engineering, inversion of control (IoC) is a design principle in which custom-written portions of a computer program receive the flow of control from an external source (e.g. a framework). The term "inversion" is historical: a software architecture with this design "inverts" control as compared to procedural programming. In procedural programming, a program's custom code calls reusable libraries to take care of generic tasks, but with inversion of control, it is the external source or framework that calls the custom code.

Inversion of control has been widely used by application development frameworks since the rise of GUI environments[1][2] and continues to be used both in GUI environments and in web server application frameworks. Inversion of control makes the framework extensible by the methods defined by the application programmer.[3]

Event-driven programming is often implemented using IoC so that the custom code need only be concerned with the handling of events, while the event loop and dispatch of events/messages is handled by the framework or the runtime environment. In web server application frameworks, dispatch is usually called routing, and handlers may be called endpoints.

  1. ^ Sweet, Richard (25 June 1985). "The Mesa Programming Environment". ACM SIGPLAN Notices. 20 (7): 216–229. doi:10.1145/17919.806843.
  2. ^ Visual_Basic_(classic)
  3. ^ Johnson, Ralph E.; Foote, Brian (June–July 1988). "Designing Reusable Classes". Journal of Object-Oriented Programming. 1 (2): 22–35. CiteSeerX 10.1.1.101.8594. Retrieved 29 April 2014.