Dev Genius

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

Follow publication

Code Smell 64 — Inappropriate Intimacy

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

Photo by Becca Tapert on Unsplash

Problems

  • Coupling
  • Bad Responsibilities Assignments
  • Bad Cohesion
  • Class Interfaces too Public
  • Maintainability
  • Extensibility

Solutions

  1. Refactor
  2. Merge
  3. Replace Hierarchy With Delegation.

Sample Code

Wrong

Right

Detection

Some linters graph class relations and protocol dependency. Analyzing the collaboration graph we can infer rules and hints.

Tags

  • Coupling

Conclusion

It two classes are too related and don’t talk much to others we might need to split, merge or refactor them, Classes should know as little about each other as possible.

Relations

More info

https://wiki.c2.com/?InappropriateIntimacy

No matter how slow you are writing clean code, you will always be slower if you make a mess.

Robert Martin

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