If you see your objects as data holders you will violate their encapsulation but you shouldn't, as in real life, you should always ask for consent.
Problems
Information Hiding Violation
Encapsulation Violation
Coupling
Solutions
- Couple to interfaces and behavior, never data.
Sample Code
Wrong
Right
Detection
You can set your linters to warn you for public attributes, setters and getters usage and discourage them.
Tags
- Coupling
Conclusion
If your classes are polluted with setters, getters and public methods you will certainly have ways to couple to their accidental implementation.
Also Known as
- Inappropriate intimacy
Relations

Code Smell 01 - Anemic Models
Maxi Contieri ・ Oct 20 '20 ・ 1 min read

Code Smell 28 - Setters
Maxi Contieri ・ Nov 19 '20 ・ 2 min read
More info
Credits
Picture by Nicolas Poussin
A data structure is just a stupid programming language.
Bill Gosper
Discussion (0)