Methods should use most fields of a class
m |
|||
Line 1: | Line 1: | ||
+ | ---- | ||
+ | <div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> | ||
+ | ---- | ||
+ | =[http://asuxoqonyb.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]= | ||
+ | ---- | ||
+ | =[http://asuxoqonyb.co.cc CLICK HERE]= | ||
+ | ---- | ||
+ | </div> | ||
:''Most of the methods defined on a class should be using most of the data members most of the time.'' --Riel's Heuristic 4.6, [[Arthur Riel 1996]] | :''Most of the methods defined on a class should be using most of the data members most of the time.'' --Riel's Heuristic 4.6, [[Arthur Riel 1996]] | ||
Revision as of 06:18, 24 November 2010
- Most of the methods defined on a class should be using most of the data members most of the time. --Riel's Heuristic 4.6, Arthur Riel 1996
This heuristic says that if methods of a class are not really using the majority of the fields in a class then that is an indication that the class may capture more than one key abstraction. If this happens, it also implies that the class is probably not very cohesive and combines data and behavior that do not really fit together.
In an extreme case, half of the methods of a class may use half of the fields, while the other half of the methods uses the remaining fields. This is clearly a violation of the heuristic and occurs because two separate concepts have been combined into one class. This class can be split in two, each capturing one of the two concepts.
This idea is similar to that used by the software metric LCOM (Lack of cohesion in methods) which is a way of measuring the cohesion in a class. It is essentially a measure of how many of the fields are used by which methods.