Eliminate irrelevant classes

From CSSEMediaWiki
Revision as of 01:05, 3 September 2008 by Elliot Fisher (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Riel's heuristic #3.7: Eliminate irrelevant classes from your design.

An irrelevant class adds no meaningful behaviour to your system for the domain you are modeling. This can apply to subclasses that inherit from a base class but do not add any functionality, which ties in with Heuristic 5.7: Avoid concrete base classes. Irrelevant classes generally have no other methods except getters, setters, and print functions. Getters and setters are not defined as meaningful behaviour because they only deal with descriptive attributes, they do not define behaviour for the domain. An exception to the getters and setters rule are sensor and transducer classes. A transducer is a device that converts an input signal of one form into an output signal of another form. A meaningful behaviour of a sensor is to get, and a meaningful behaviour of a transducer is to set.

A typical way to eliminate such classes is to demote the class to an attribute of another class. You do not necessarily have to completely remove the information from the design.

See also