For example, in Java, you could design a Square class that required a “height” and “width” to be passed in via its constructor. You could define that both height and width must be integers, and if code exists that attempts to create a Square by passing in something other than integers the code would fail to compile. No test would be created to guard against this. What might be a run-time error would be caught instead at compile time.
TDD can help here for those who prefer dynamic typing. When such a restriction is deemed important extra tests can be added to ensure that critical parameters are of the correct type, moving the detection of potential errors from run-time to test-time.
This is Scott Bain. Visit us at www.netobjectives.com.