Code Smell 68 - Getters
Getting things is widespread and safe. But it is a very bad practice.
Problems
Naming
Information Hiding
Coupling
Encapsulation Violation
Mutability
Anemic Models
Solutions
Avoid Getters
Use domain names instead
Protect your implementation...
maximilianocontieri.com1 min read
Rodrigo
Without pressure, there isn't action
Interesting article Maxi Contieri. If I get it right (see what I did there ) getters could be fine to be used if we assign a better name by removing the ¨get¨prefix and using a domain name instead. Another restriction is that we should use them only on safe operations, such as reading.
They become a problem when we expose the object internals to mutate its data from the outside, breaking encapsulation as consequence, is that right?