Curious question — why do people insist so much on fields being private and there being getters and setters, even when all that getters do is return the field and all that setters do is set it? What kind of problem does this arrangement solve? Why not just use public fields?
getters and setters prevent other objects from modifying internal properties in unexpected ways. Having that encapsulation and abstraction is important for maintainable code. Also, getters and setters don't always modify individual values. Imagine a class where we have: private val firstName private val lastName fun returnFullName(): return firstName + lastName
Except I'm talking about Java classes that store data. They don't do any operations on it, they don't have any internal state, they're more like C structs.
> Also, getters and setters don't always modify individual values.
Of course. But one doesn't contradict the other.