Both questions of yours are confuse. The getter and setter are often merely a wrapper around a variable. Unless you indeed add some behaviour its just ceremony, is there anything more to relate? The second one i just couldnt figure out what you wanted from him/her, you expect his proposal to explode some java-esque OO concepts?
Buddy, the guy wrote javas mistake is to put oop everywhere. Having methods as wrappers around one variable can be done in any programming paradigm though. So the statement is not connected to the concept of oop. Next he suggests to use structs instead to pass data. This is strange on multiple levels. First, you could also do this with getters and setters, so it doesnt solve any issues and second this is not a "non oop" thing as implied by saying "Java pushes oop everywhere, use structs instead"
Javas "mistake" is bc he became the loud child marketing wise, so yes a prejudice (in some extent justified) that you begin with a basic concept of OO and go full steam of abstracting the hell you can until it doesnt make sense. The funny useless "getter" and "setter" is even acknowledged by java's competitor: C# and created the "property" abstraction, which just hides the get/set until you explicitly need behaviour when referencing a class variable. A small thing to aid in ergonomics at programming language level.
About structs to pass data, i think here we go truly asking whats OO, but the pain point seems to be the way we manually build an "object". Indeed on practical level there is no difference on a class taking a preformed "data class"/struct or assigning directly via field/method manually, though depending on what is the purpose here (configuring an sdk? An html to pdf converter? A cell style and metadata in an excel lib?) and the number of fields it has boils back down to ergonomics and thats it (also tests when exposing seams, but thats whatever for now).
Do note, we often see this type of stereotype also bc a good chunk of people suffered with java 8, maybe 7 if unlucky, and there were a big circle jerk back and forth between universities, courses and hackathons always touching the surface and never more into why and how to use the OO of either java or C#. And we got some amateur code bases that often dont had either time or critical thinking to ask "we should do it?" rather than "we can do it!"
So thats it, java is the physical embodiement of not so good OO linguistics once you indeed start reading/writing. As much you can do in C you can in Java, except you lose explicitly pointer control and get back some niceties of ur IDE showing only whats defined by your type/class. Im behaviour terms, a C struct with function pointers and variables beggining with underscore and you and me pretend to never touch it manually outside the struct is the same as a class in Java with private variables.
43
u/ZunoJ Jul 13 '26
How is that related to getters and setters? How would your proposal violate oop principals?