Everything I hold is a hammer

People use subclassing too much.

The is-a relationship is a powerful one. All too often I see subclassing being used to save typing, rather than to express that an object really is a refinement of another.

If you have a Vehicle class that has a VIN attribute, a ToyCar probably does not belong as a subclass of Vehicle. Sure, you could return null or throw an exception or something. But are you really going to ride in a toy car, or report its sale to the DMV? You can rationalize, but the fact remains that the VIN attribute either belongs somewhere else, or ToyCar needs to go elsewhere.

Rule of thumb: If you’re designing classes to saving keystrokes, you’re probably in trouble.

Author: landon

My mom thinks I'm in high tech.