Dev Genius

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

Follow publication

Code Smell 34 — Too Many Attributes

Maximiliano Contieri
Dev Genius
Published in
1 min readNov 25, 2020

Photo by Andy Li on Unsplash

Problems

  • Low Cohesion
  • Coupling
  • Maintainability
  • Readability

Solutions

  1. Find methods related to attributes.
  2. Cluster these methods.
  3. Break the object related to those clusters.
  4. Find real objects related to this new objects and replace existing references.

Examples

  • DTOs
  • Denormalized table rows

Sample Code

Wrong

Right

Detection

Most linters warn when you declare too many attributes. Setting a good warning threshold should be easy.

Tags

  • Primitive

Conclusion

Bloated objects know too much and are very difficult to change due to cohesion.

Developers change these objects a lot, so they bring merge conflicts and are a common problems source.

Relations

So much complexity in software comes from trying to make one thing do two things.

Ryan Singer

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