March 2015
Intermediate to advanced
236 pages
5h 26m
English
Our new code represents a small change to the design of the system. Before, the Http instance was created by the retrieve() method as a private detail of the AddressRetriever class. Now, any client that interacts with AddressRetriever is responsible for creating and passing in an appropriate Http instance, perhaps something like:
| | AddressRetriever retriever = new AddressRetriever(new HttpImpl()); |
Is changing your system’s design just to write a test a bad thing? No, because it’s most important to demonstrate, in a simple fashion, that the system behaves the way you expect. Also, you have a better design: the dependency on Http is now declared in the clearest way possible, and moving the dependency to the ...
Read now
Unlock full access