Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Follow publication

Code Smell 63 — Feature Envy

Maximiliano Contieri
Dev Genius
Published in
2 min readMar 23, 2021

Photo by Hisu lee on Unsplash

Problems

  • Coupling
  • Low Reuse
  • Low Testability
  • Bad Responsibilities Assignment
  • Bijection Fault

Solutions

  1. Move method to the appropriate class.

Sample Code

Wrong

Right

Detection

Some linters can detect a sequential pattern of collaborations with another object.

Tags

  • Coupling

Conclusion

  • We should assign responsibilities according to real object mappers and avoid abusing other objects protocol.

Relations

More info

We argue that design practices which take a data-driven approach fail to maximize encapsulation because they focus too quickly on the implementation of objects. We propose an alternative object-oriented design method which takes a responsibility-driven approach.

Rebecca Wirfs-Brock

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Written by Maximiliano Contieri

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com

No responses yet

Write a response