Limit compositions in a class
From CSSEMediaWiki
(Difference between revisions)
(New page: This heuristic assumes that most of the methods in a class should be using most of the data members most of the time. This will then require implementors to think about all the data member...) |
m |
||
Line 1: | Line 1: | ||
+ | :''Classes should not contain more objects than a developer can fit in his or her short term memory. A favorite value for this number is six.'' -- [[Arthur Riel 1996]]. | ||
+ | |||
This heuristic assumes that most of the methods in a class should be using most of the data members most of the time. This will then require implementors to think about all the data members of the class while writing methods. If there are too many to think about, then this will lead to items being ommited and bugs creeping into the code. Seven plus or minus two is the widely accepted number of items that people can keep in their short term memory. Riel suggests that six is the optimum number as it takes into consideration those with poor short term memories and that there are other factors such as the fact that methods usually take in an argument or two. | This heuristic assumes that most of the methods in a class should be using most of the data members most of the time. This will then require implementors to think about all the data members of the class while writing methods. If there are too many to think about, then this will lead to items being ommited and bugs creeping into the code. Seven plus or minus two is the widely accepted number of items that people can keep in their short term memory. Riel suggests that six is the optimum number as it takes into consideration those with poor short term memories and that there are other factors such as the fact that methods usually take in an argument or two. | ||
+ | |||
+ | [[Category:Riel's heuristics]] |
Revision as of 04:12, 22 July 2009
- Classes should not contain more objects than a developer can fit in his or her short term memory. A favorite value for this number is six. -- Arthur Riel 1996.
This heuristic assumes that most of the methods in a class should be using most of the data members most of the time. This will then require implementors to think about all the data members of the class while writing methods. If there are too many to think about, then this will lead to items being ommited and bugs creeping into the code. Seven plus or minus two is the widely accepted number of items that people can keep in their short term memory. Riel suggests that six is the optimum number as it takes into consideration those with poor short term memories and that there are other factors such as the fact that methods usually take in an argument or two.