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 🙂

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.