Construct classes from the outside in

When experimenting with the design of a new class, it's very helpful to approach the task from the point of view of the caller: Much of design is summed up simply as: The critical step seems to be the second. The best techniques are those which discover the errors the fastest. Coding "from the outside in" seems to perform very well in this regard.

Constructing a non-private method from the outside in might involve these steps:

In effect, such techniques use the programming language itself as a design tool.

See Also :
Use a testing framework (JUnit)
Use javadoc liberally
Separate public and private members
Design by Contract