Limit compositions in a class
From CSSEMediaWiki
Revision as of 03:52, 22 July 2009 by Michael Madamba (Talk | contribs)
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.