
Getters and Setters are Code Smells. Getting things is widespread and safe. But it is a very bad practice.
Software Engineer
I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
Markdown supported · ⌘↵ to post
Rodrigo
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?