A class defines objects with lots of attributes.
Problems
Low Cohesion
Coupling
Maintainability
Readability
Solutions
- Find methods related to attributes.
- Cluster these methods.
- Break the object related to those clusters.
- 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
Code Smell 10 - Too Many Arguments
Maxi Contieri ・ Oct 29 '20
Credits
So much complexity in software comes from trying to make one thing do two things.
Ryan Singer
Top comments (7)
two sample codes are the same.
Yeah, I was comparing them for 10 mins lol
sorry. there's a bug in dev.to
This is not the first time they report it on my code smell articles.
files ARE different and of course code is different.
They have commented it is a bug in Mobile App.
Will report it to dev.to team
I'm leaving the hyperlinks here as plan B
Wrong
gist.github.com/mcsee/b6c664aef324...
Right
gist.github.com/mcsee/c34dd227f16b...
Ah, I see!
I was viewing it from the PWA so I guess I got to see the same.
Anyways, Well written!
thank you!!
I think that your solution solves only the readability problem. Is it so?
No. it also creates testable abstractions and cohesive new objects. will add to code to clarifiy