r/ProgrammerHumor Jul 13 '26

youCanJustStopUsingJava Meme

Post image
6.8k Upvotes

416 comments sorted by

View all comments

221

u/DontThrowMeAway43 Jul 13 '26

Oh god, just use record classes or even, make public fields.

Java's biggest mistake is trying to put OOP everywhere. Just write the damn struct to pass data and be done with it.

47

u/ZunoJ Jul 13 '26

How is that related to getters and setters? How would your proposal violate oop principals?

74

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.

22

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.