Hardwired dependencies Part 1: An alternative to Dependency injection.

JAVING
1 min readJun 15, 2020

--

In this video, I show a little refactoring trick that can be used to unit test a method that has a hardwired dependency to an external system via an static method call. This is an alternative approach to dependency injection, which can be used when we are not sure about modifying the design of the class. In very large systems making design decisions such as adding another method to a constructor etc … may have a big impact in design of both production and test harnesses. This trick can help you temporarily postpone your design decision and get you going with your unit testing.

Originally published at http://javing.blogspot.com/2017/04/dealing-with-hardwired-dependencies.html

If you enjoyed this story, please guy us some claps and follow us

--

--

JAVING
JAVING

Written by JAVING

The present continuous form of “to program in Java”.

No responses yet