Skip to content

Feature Envy

Medium — good to knowArchitecture

ELI5 — The Vibe Check

Feature envy is when a function spends more time poking around in another class's data than its own. It's like a neighbor who's always borrowing your tools — at some point, the function should just move to where the data lives. If your method calls other.getX(), other.getY(), other.getZ() more than it uses its own stuff, it's jealous of the wrong class.

Real Talk

Feature envy is a code smell where a method accesses data from another object more than its own. Identified by Martin Fowler, it suggests the method belongs in the other class. The refactoring solution is typically Move Method — relocating the method to the class whose data it primarily uses, improving cohesion and reducing coupling.

When You'll Hear This

"This method has serious feature envy — it calls the User object 15 times." / "Move the method to where the data lives and kill the feature envy."

Made with passive-aggressive love by manoga.digital. Powered by Claude.