«The technique that makes you feel like Tony Stark.» Prompted by the Author

Member-only story

Improve Your Testing #16: Simplify Your Dependencies

Stop fighting with mocks and stubs. Master dependencies by treating them as simple configuration.

David Rodenas PhD
10 min readDec 7, 2024

--

I still remember when I saw this scene from the Iron Man movie. In it, Tony Stark was moving hardware and software pieces in the air and connecting them, just like Lego pieces. Upon seeing it, my first reaction would have been: this is impossible, software doesn’t work like that. But this time was different. This time I knew about and had been working with a new technique called Dependency Injection. This technique is what made me feel capable of handling software modularly like Tony Stark did.

The Power of Configuration

One thing I’ve observed is that understanding what Dependency Injection is can be very difficult. It often takes years of practice to fully understand what it enables, and even then we don’t completely grasp its potential. That’s why I want to present it from a different perspective.

In fact, Dependency Injection is nothing more than a configuration system. So let’s look at an example in an application.

Let’s imagine a library application. It will have a database, an email service for sending reminders, and a logging service. The configuration could be as…

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

Responses (2)