Qualified Subclass Name

Subclasses are somehow different from their superclasses. Use adjective prefixes to a SimpleSuperclassName to reveal differentiation. Compound noun phrases can be used as well. This leads the reader to an understanding of the purpose of the class. For instance, Task is a good name for a superclass. Connectable_Task is a phrase name which can be used for a subclass. The name provides context information, e.g, it is Connectable, it is a Task. However, this can become unwieldy in deep hierarchies. On the positive side, it can give you some feedback about the depth of your hierarchies.

If you are about to subclass with a QualifiedSubclassName it is probably also a good time to consider whether you should be subclassing or just adding that new capability to the superclass.

-- MichaelFeathers


You don't have to name a subclass after its immediate superclass. You want to communicate two things with a subclass name- what it's like and how it's different. Therefore, if I am inheriting for implementation purposes down in the Task hierarchy, I don't mind just calling it ConnectableTask?. --KentBeck


EditText of this page (last edited March 22, 1998) or FindPage with title or text search