Buzzword Buster – IoC

Yan Cui

I help clients go faster for less using serverless technologies.

Definition:

Inversion of Control (IoC) refers to the inversion of the flow of control (the order in which individual statements, function calls, etc. are executed) in a software. You’ll often hear the term Hollywood principle being mentioned in the same breath as IoC, it simply states "Don’t call us, we’ll call you" which more or less sums up the principles of IoC.

Purpose:

In traditional software design, the flow of control is governed by a central piece of code which often have to address multiple concerns (logging, validation, etc.) and need to be aware of the implementation details of its dependencies. This creates a very tightly coupled application where changes in one component have a ripple effect throughout the rest of the application.

Following the principles of IoC can help you achieve:

  • decoupling of execution of a task from implementation (through the use of interfaces)
  • greater separation of concerns (each component only focuses on what it’s designed to do)
  • more flexibility (implementation can be easily changed without any side effects on other components)
  • more testable code (enables the use of stubs/mocks in place of concrete classes intended for production)

Advantages:

  • Simplifies the building of specific tasks.

Disadvantages:

  • Has the potential to make the flow of control in an application more complex, and therefore making it harder to follow.

Parting thoughts..

  • Misusing or abusing IoC can result in Macaroni code.
  • IoC is not a silver bullet for all your system engineering problems, and remember, "Don’t fix what’s not broken"
  • When adopting IoC, there is additional training needs for new joiners to the team.
  • Design systems for flexibility, which allows quick adaptation to changing environment/requirementsimage
  • Avoid complicating system design by trying to be future-proof upfront, you can’t predict the future! image

Further readings:

.NetRocks show 362 – James Kovac Inverts our Control!

Loosen Up – Tame Your Software Dependencies For More Flexible Apps (MSDN article by James Kovac)

Design Pattern – Inversion of Control and Dependency Injection (by Shivprasad Koirala)


 

Whenever you’re ready, here are 4 ways I can help you:

  1. If you want a one-stop shop to help you quickly level up your serverless skills, you should check out my Production-Ready Serverless workshop. Over 20 AWS Heroes & Community Builders have passed through this workshop, plus 1000+ students from the likes of AWS, LEGO, Booking, HBO and Siemens.
  2. If you want to learn how to test serverless applications without all the pain and hassle, you should check out my latest course, Testing Serverless Architectures.
  3. If you’re a manager or founder and want to help your team move faster and build better software, then check out my consulting services.
  4. If you just want to hang out, talk serverless, or ask for help, then you should join my FREE Community.

 


Leave a Comment

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