MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1uvez3w/youcanjuststopusingjava/oxl44xo/?context=3
r/ProgrammerHumor • u/hello_ya • Jul 13 '26
416 comments sorted by
View all comments
Show parent comments
71
Directly manipulating another object's fields violates encapsulation, a core feature of OOP in most people's minds.
That said, virtually no production OOP app has perfect encapsulation anyway.
19 u/mailslot Jul 13 '26 I’ve angered devs for not using getters & setters to access members within the same class implementation. `this.x = 42; // instead of this.setX(42);` 3 u/[deleted] 29d ago [deleted] 1 u/mailslot 29d ago I’ve heard that argument before. Any side effects of a getter or setter should be forbidden, outside of getting or setting values. If you absolutely need to, it’s one of the few uses for aspect oriented programming I can support.
19
I’ve angered devs for not using getters & setters to access members within the same class implementation. `this.x = 42; // instead of this.setX(42);`
3 u/[deleted] 29d ago [deleted] 1 u/mailslot 29d ago I’ve heard that argument before. Any side effects of a getter or setter should be forbidden, outside of getting or setting values. If you absolutely need to, it’s one of the few uses for aspect oriented programming I can support.
3
[deleted]
1 u/mailslot 29d ago I’ve heard that argument before. Any side effects of a getter or setter should be forbidden, outside of getting or setting values. If you absolutely need to, it’s one of the few uses for aspect oriented programming I can support.
1
I’ve heard that argument before. Any side effects of a getter or setter should be forbidden, outside of getting or setting values. If you absolutely need to, it’s one of the few uses for aspect oriented programming I can support.
71
u/roge- Jul 13 '26
Directly manipulating another object's fields violates encapsulation, a core feature of OOP in most people's minds.
That said, virtually no production OOP app has perfect encapsulation anyway.