Feature envy smell
From CSSEMediaWiki
(Difference between revisions)
(Created and wrote up the page) |
m |
||
Line 1: | Line 1: | ||
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|refactoring]] should be applied. | 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|refactoring]] should be applied. | ||
− | Discretion still needs to 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 == | == Refactoring Methods == |
Revision as of 23:05, 15 September 2008
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