Feature envy smell
From CSSEMediaWiki
Revision as of 23:04, 15 September 2008 by Kris Nicholson (Talk | contribs)
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