Make Testing Easy
Build software artifacts in such a way that defects are easily found through testing. Designing for testability up front can be difficult without knowing the control points and observation points of the System Under Test (SUT). Following the XP principle of Test First will force us to build for testability. Avoid retrofitting unit tests on top of existing code. If that code is not built for testability, you will struggle to write good tests and greatly diminish Defect Localization.
The example below illustrates how to improve testability through application of the Dependency Inversion Principle. This is a very effective method of isolating the System Under Test (SUT), enabling the substitution of test doubles in place of dependencies.