Separate methods that do not communicate

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 8: Line 8:
 
* [[Design maxims]]
 
* [[Design maxims]]
 
* [[Johnson and Foote 1988]]
 
* [[Johnson and Foote 1988]]
 +
* [[Single responsibility principle]]

Revision as of 22:56, 6 October 2008

If there are different ways to view different objects in a class, then it is a good signal that such a class needs to be split. In a good design, a class should only represent a single type of object entity. If there is different type of entities can be seen from the class than more specialized subclass is needed. This also conforms to the single responsibility principle.

A good way to tell us whether our design of a class is need to be split is by checking whether there are methods in a class which do not communicate. No-communicating method is a good indication of separate concerns the particular class is taking responsible for. Then as a result, it needs to be split.

Riel's Heuristic Beware of non-communicating methods is derived from this.

See also

Personal tools