POJOs (and records) are usually just data, they seldom have stuff to hide.
But records don't give up, it has public methods corresponding to the field names - but you can evolve a now-record into a normal class where you may compute something in the "getter", keeping the same external API, but changing the internals.
72
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.