Avoid verb classes

From CSSEMediaWiki
Revision as of 02:52, 22 July 2009 by TobiW (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Class names should always consist of nouns, mostly in singular since one instance of that class will be created at a time. Classes represent real or abstract objects (like cars or computing structures) and therefore shouldn't have a verb name.

If a class name is a verb, this is a strong indicator that the functionality of that class can be put into an existing class. For example, the Interface Move in the Frogs design contains only three abstract method definitions. The ability to move by swimming or hopping belongs to the frog, though. If a superclass of frog is desired, the class should have the name Movable or Movable Object.

Personal tools