Chapter 7: Analog Objects
1. The TDD can not be encountered, writing testing, is: target a special test (Ideally, there is only one assertion of each test); independent of each other (each test has the establishment of the preset environment and Clear so that the test can be run in any order); the running speed is fast (can run the test frequently).
2. Monthly, independent and execution speed has a certain contradiction, because it must be reasonably handled resource, and the simulation object (Mock Object) provides a certified successful solution. It is used when it is difficult or impossible to create a status of a need for a difficult resource creation or access resource is limited.
3. The idea behind the analog object is to create a lightweight, controllable object instead of using the object to write tests. The analog object also allows you to specify and test your code and the interaction between the analog object itself.
4. The extraction interface is a common way for analog objects.
5. The analog object helps to maintain the loose coupling of the design (centering for the interface, eliminating the internal implementation of the object); check the code uses another object to be due (can set the expected value in the analog object); Use TDD (by setting the return value in the analog object loyalty, you can provide specific information for the currently developed code); you can make the test faster (avoiding the real connection resource); easier to develop and hardware device remote The system is difficult to handle the resource to interact (Proxy Layer), to isolate the actual resources); postponed the necessary class implementation (a class that requires a lot of energy); advocates interface-based design ( Such design style is worth promoting); encouraging composition rather than inheritance; improving interface (roasting and modifying interface, there is an opportunity to think out early); can test unusual and uncommon exceptions.
5. The analog object helps to maintain the loose coupling of the design (centering for the interface, eliminating the internal implementation of the object); check the code uses another object to be due (can set the expected value in the analog object); Use TDD (by setting the return value in the analog object loyalty, you can provide specific information for the currently developed code); you can make the test faster (avoiding the real connection resource); easier to develop and hardware device remote The system is difficult to handle the resource to interact (Proxy Layer), to isolate the actual resources); postponed the necessary class implementation (a class that requires a lot of energy); advocates interface-based design ( Such design style is worth promoting); encouraging composition rather than inheritance; improving interface (roasting and modifying interface, there is an opportunity to think out early); can test unusual and uncommon exceptions.