About the Principles found in Java Structures

Java Structures features a number of programming principles not openly advocated in other data structures texts. Java Structures presents the reasoning behind rules-of-thumb that help designers of data structures make the best design decisions possible. Here are a few of the principles:

The principled programmer understands a principle well enough
to form an opinion about it.

Free the future: reuse code.

Design and abide by interfaces as though you were the user.

Declare data fields protected.

Test assertions in your code.

Maintaining consistent interfaces among classes
makes a package useful.

Recursive structures must make progress toward a base case.

When manipulating references, draw pictures.

Every public method of an object
should leave the object in a consistent state.

Symmetry is good.

Question asymmetry.

Test the boundaries of your structures and methods.

Understand the complexity of the structures you use.

Never modify a data structure
while an associated Enumeration is live.

Assume values returned by iterators are read-only.

Declare parameters of overriding methods
with the most general types possible.

Avoid multiple casts of the same object
by assigning the value to a temporary variable.

Consider your code from different points of view.

Don't let opposing references show through the interface

Use wrappers to provide a consistent interface to recursive structures.

Write methods to be as general as possible.

Avoid unnaturally extending a natural interface.

Seek structures with reduced friction.

Declare object-independent functions static.

Provide a method for hashing the objects you implement.

Equivalent objects should return equal hash codes.

Make it public and they will use it.

Fight imperfection.