[Tutor] designing POOP

Kent Johnson kent37 at tds.net
Fri Feb 8 13:00:36 CET 2008

Alan Gauld wrote:

> Unit tests and TDD is not a design technique per se.
> It is definitely not a technique for designing OOP programs
> its a programming technique that makes code more reliable
> (whether OOP or not).
> Where it does help in design is by focussing attention
> on how a class (or function) should behave from the consumers
> perspective.

I agree that TDD is not a design technique, but it does strongly 
influence design by introducing testability as a design requirement. TDD 
strongly encourages loose coupling and reusability.
- loose coupling because classes and functions that depend on many other 
classes/functions/modules are harder to test
- reusability because of the loose coupling and because any code that 
has unit tests already has two clients - the production code and the tests.

I like to say, no code is reusable until it has been reused. Although a 
bit of an overstatement, there is a lot of truth in it. It is very hard 
to anticipate how a bit of code might be reused without actual reuse. 
TDD provides an artificial second use which promotes reusability.

TDD also promotes incremental development where the design evolves to 
meet current requirements. This is sometimes called Test-Driven Design:

So TD development can be part of a process that includes design.


More information about the Tutor mailing list