Feature envy smell

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m (category)
m (See Also)
Line 13: Line 13:
 
*[[Code smells]]
 
*[[Code smells]]
 
*[[Coupling and cohesion]]
 
*[[Coupling and cohesion]]
 +
 +
{{Template:CodeSmells}}
  
 
[[Category:Code smells]]
 
[[Category:Code smells]]

Revision as of 09:34, 14 October 2009

The feature envy smell is present when a class or a method or methods from that class use methods from another class excessively, in particular if a method seems more 'interested' in another class than its own. This is a good sign that some refactoring should be applied.

Discretion still needs to be applied since particular library methods may get used a lot, but this doesn't necessarily mean we should try to refactor around this.

Refactoring Methods

  • Move Method - if a particular method is using methods from another class excessively, move it to that class
  • Extract Method - if only a part of a method is envious
  • Extract Class - if several methods are envious and they don't belong in the envied class either

See Also


Personal tools