An Interest In:
Web News this Week
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
November 25, 2020 03:07 am GMT
Original Link: https://dev.to/mcsee/code-smell-34-too-many-attributes-584p
Code Smell 34 - Too Many Attributes
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 1 min read
#codenewbie #beginners #100daysofcode #oop
Credits
So much complexity in software comes from trying to make one thing do two things.
Ryan Singer
Original Link: https://dev.to/mcsee/code-smell-34-too-many-attributes-584p
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To