Avoid interface bloat
From CSSEMediaWiki
(Difference between revisions)
m |
|||
Line 2: | Line 2: | ||
This heuristic refers to the idea that only those members which are supposed to be used from outside the class should be exposed in the public interface. If two or more methods of a class have some code in common, it is common to encapsulate it in its own method (a common-code private function). This method is an implementation detail, however, and should not be exposed publicly. | This heuristic refers to the idea that only those members which are supposed to be used from outside the class should be exposed in the public interface. If two or more methods of a class have some code in common, it is common to encapsulate it in its own method (a common-code private function). This method is an implementation detail, however, and should not be exposed publicly. | ||
+ | |||
+ | ==See Also== | ||
+ | *[[Avoid interface pollution]] | ||
[[Category:Riel's heuristics]] | [[Category:Riel's heuristics]] |
Revision as of 23:39, 20 July 2009
- Do not put implementation details such as common-code private functions into the public interface of a class. --Riel's Heuristic 2.5, Arthur Riel 1996
This heuristic refers to the idea that only those members which are supposed to be used from outside the class should be exposed in the public interface. If two or more methods of a class have some code in common, it is common to encapsulate it in its own method (a common-code private function). This method is an implementation detail, however, and should not be exposed publicly.