Avoid verb classes

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: 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 co...)
 
(Added See also section)
Line 2: Line 2:
  
 
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''.
 
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''.
 +
 +
== See also ==
 +
[[Eliminate irrelevant classes]]

Revision as of 02:54, 22 July 2009

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.

See also

Eliminate irrelevant classes

Personal tools