Feature envy is a code smell: one component performs several tasks mainly by using another component’s features. It behaves as though it wants to be that other component. section 10.2.1
Recognize and reduce feature envy by:
- Noticing code that directly calls several operations from another module or class. section 10.2.1 section 10.3
- Moving the related behavior to a single entry point in the component that owns it. section 10.2.1
- Trusting the abstraction’s interface afterward and using tests to maintain confidence in hidden behavior. section 10.2.1
Query cleaning and bookmark commands
Query-cleaning logic originally required the consumer to call several search functions. Moving it into search.clean_query lets callers request a cleaned query without knowing the internal steps. In Bark, direct calls such as db.add('bookmarks', data) show feature envy alongside tight coupling. section 10.2.1 section 10.3
Use the figure to inspect feature envy between classes. section 10.2.1
