I'll Be Backend
Code smells

Feature Envy: Move Logic to Its Data

Feature envy is a code smell: a method that uses another object's data more than its own. When that method gets copied to a second class, the rule lives twice and the copies drift. These lessons count whose data each line reads, then move the calculation into the object that owns the data, one safe refactoring at a time.

Pick your language

When to use it

Use it when

A method reads several fields of one object and few of its own.

Skip it when

The divisor differs per carrier, so the rule reads carrier data too, or the object is plain data crossing a boundary.

Spot it by

A run of getter calls on one parameter, and the same math wherever that object goes.