James Ladd proposes a compass that we can use to navigate our object-oriented designs. We move North as we travel up a layer, South as we travel down a layer. West will take us away from the object, and East moves us towards another object.
James suggests that we orient our code so that we are always travelling East. In practice this means that code should follow these rules:
- All public methods return nil, boolean or return a reference to the current object (self).
- Objects that implement the Factory or Builder pattern or similar are an exception.
- East is better suited to composite objects, not primitive objects (James doesn’t make this distinction).