Inversion of Control

Photo by Jasper Garrat on Unsplash

In his post “Inversion of Control” Kent C. Dodds starts off with a simple filter function and how it can quickly become a mess as features creep in. Using IoC it’s possible to keep the implementation, diverting some responsibilities away from it:

We changed the responsibility of deciding which element gets in the new array from the filter function to the one calling the filter function. Note that the filter function itself is still a useful abstraction in its own right, but it’s much more capable.

And yes, of course Kent wings back to React in his post. What else would you have expected? 😉

Inversion of Control →

IoC (and DI) are big themes in the PHP world, but not that much in the JS world. Good to read that it also gets some explicit attention in the JS world now 🙂

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

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.