Feature envy smell
From CSSEMediaWiki
Revision as of 09:34, 14 October 2009 by Matthew Harward (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
See Also