Separate methods that do not communicate
From CSSEMediaWiki
(Difference between revisions)
m |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | If there are different ways to view different objects | + | If there are different ways to view different objects of the same 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 a single class can be viewed as representing multiple concepts then it is likely that this class should be split. This also conforms to the single responsibility principle. |
− | A good way to tell us whether | + | A good way to tell us whether a class needs to be split is by checking whether there are methods in a class which do not communicate. Non-communicating methods is a good indication that there are multiple concerns within one class, and therefore it needs to be split. |
Riel's Heuristic [[Beware of non-communicating methods]] is derived from this. | Riel's Heuristic [[Beware of non-communicating methods]] is derived from this. | ||
Line 8: | Line 8: | ||
* [[Design maxims]] | * [[Design maxims]] | ||
* [[Johnson and Foote 1988]] | * [[Johnson and Foote 1988]] | ||
+ | * [[Single responsibility principle]] | ||
+ | |||
+ | [[Category: Johnson and Foote's heuristics]] |
Latest revision as of 01:35, 18 August 2009
If there are different ways to view different objects of the same 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 a single class can be viewed as representing multiple concepts then it is likely that this class should be split. This also conforms to the single responsibility principle.
A good way to tell us whether a class needs to be split is by checking whether there are methods in a class which do not communicate. Non-communicating methods is a good indication that there are multiple concerns within one class, and therefore it needs to be split.
Riel's Heuristic Beware of non-communicating methods is derived from this.