jargon

Comparison

Feature envyvsMessage chain

Feature envy

the method calls five getters on another object and one on itself, so it belongs on that other object.

A method more interested in another class's data than in its own, which is a signal that it is on the wrong class. Moving it puts the behaviour with the data it operates on, which usually lets several of those getters become private. It is the smell that tell-don't-ask is a rule about, and it is the easiest one to spot mechanically.

Full entry →

Message chain

the line is four dots long and a change to any object along the way breaks the code at the end of it.

Navigating through a chain of objects to reach the one you actually want, which couples the caller to every structure along the path. It is the violation the Law of Demeter names, and the standard fix is to ask the nearest object for what you need so the traversal happens where the structure is known. Fluent interfaces look identical and are not the same thing — each call there returns the same receiver by design.

Full entry →

Related comparisons