Feature Envy Smell

This page is about the CodeSmell. For another meaning, see FeatureEnvy.

"The whole point of objects is that they are a technique to package data with the processes used on that data. A classic [code] smell is a method that seems more interested in a class other than the one it is in. The most common focus of the envy is the data."

[An inherited object seems awful envious of the class it is inheriting from. Also, the object seems awful envious of the libraries of the operating system that the object is wrapping. I don't think we should use phrases like interested, since code and machines do not have human qualities such as interest or envy. Rephrased, one could claim that a method which references or calls too many other methods and data existing in other classes is a CodeSmell. However, I'm not so sure this is true - as some classes heavily wrap (i.e are envious of) operating system libraries (which could be considered classes).]

Local example in ManifestResponsibility.

Refactor using CategoryCodeSmell

EditText of this page (last edited April 30, 2009)
FindPage by searching (or browse LikePages or take a VisualTour)