Feature Envy

Feature envy reveals a method (or method-to-be) that would work better on a different class.

Symptoms

  • Repeated references to the same object.
  • Parameters or local variables which are used more than methods and instance variables of the class in question.
  • Methods that includes a class name in their own names (such as invite_user).
  • Private methods on the same class that accept the same parameter.
  • Law of Demeter violations.
  • Tell, Don’t Ask violations.

Solutions

Prevention