Use unit tests to simplify code modification.
Consider testing during programming: Use the class method to replace the method. In this way, you can write the inheritance class in the test to change the behavior of the corresponding method to avoid executing certain functions, better solution to dependencies.
Use header files containing preprocessing to create seams. # Ifdef testing... Endif
By modifying the contained path of the link, you can also write a class specifically used for testing. (Best, clear, and easy to maintain test code)
If the internal functions called by the function are multi-state, the internal functions are controlled through passing parameters through the base class object, and the behavior of the internal functions is controlled through the test object, instead of encapsulating the new objects inside the function.
Use the protected function instead of static and private functions to facilitate subclass.
Include modifications:
New method, new class
The outer method calls the original method in the new method.
Overwrite class
Keep the signature. The called function parameters are the same as the original ones to avoid errors.
Art notes for modifying code