Thursday, April 6, 2017
Dealing with Hardwired dependencies part 1 - An alternative to Dependency injection.
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.
Labels:
code smell,
hard wired dependency,
java,
Refactoring,
Unit Testing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment