Back to Catalog
Code Smells
Dispensables
Data Class
Classes that only contain data and no behavior.
Intent & Description
'
π― Intent
Identify classes that are essentially data containers with no meaningful behavior.
π Context
You have classes that only contain fields and getters/setters, with no business logic or behavior.
π‘ Solution
Move behavior from client classes into the data class, or eliminate the data class if it’s not adding value.'
Real-world Use Case
Use when classes are pure data containers with no behavior.
Source
π TL;DR
Classes with only data and no behavior should either have behavior added or be simplified to structures.