Inappropriate intimacy smell

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: Sometimes classes become too intimate and spend too much time touching each other's private parts or fields. This is bad because it breaches encapsulation and Information hiding. If ...)
 
m (Reverted edits by Ebybymic (Talk); changed back to last version by Matthew Harward)
 
(3 intermediate revisions by 3 users not shown)
Line 10: Line 10:
 
* [[Hide data within its class]]
 
* [[Hide data within its class]]
 
* [[Keep related data and behavior in one place]]
 
* [[Keep related data and behavior in one place]]
 +
* [[Code smells]]
 +
 +
{{Template:CodeSmells}}
 +
 +
[[Category:Code smells]]

Latest revision as of 03:03, 25 November 2010

Sometimes classes become too intimate and spend too much time touching each other's private parts or fields. This is bad because it breaches encapsulation and Information hiding.

If a class is more interested in the internals of another class, this can indicate that related data and behavior is not put in one place. Therefore, intimate classes should be refactored by moving the methods and fields in such a way that related data and behavior is put together and there is no need for a class to look at another class' internals.

Subclasses in particular are often very intimate with their parent classes though proponents of object encapsulation would argue that that is appropriate.

See also


Personal tools