Comment on Typing is not a programming bottleneck
onlinepersona@programming.dev 1 year ago
I agree, typing is not a bottleneck, repeating yourself is. All that boilerplate code in the example, shouldn’t have to be written. It’s wasted time.
Comment on Typing is not a programming bottleneck
onlinepersona@programming.dev 1 year ago
I agree, typing is not a bottleneck, repeating yourself is. All that boilerplate code in the example, shouldn’t have to be written. It’s wasted time.
philm@programming.dev 1 year ago
The curse of OOP (java style…).
I mean why do you need to write getter and setter methods. I have wondered at the beginning of university 10 years ago, and am still wondering why you would need something like that…
Dunstabzugshaubitze@feddit.de 1 year ago
You let your ide generate simple getters and setters or utilize something that generates them during a compilation process.
Who ever writes them per hand needs to utilize their tooling better or needs better tooling.
philm@programming.dev 1 year ago
Yeah but why do I have to use an IDE to generate getters and setters in the first place? It just adds up to more mental overhead, because my brain has to process this boilerplate somehow, even if my IDE can generate it (I know it’s simple code, but it’s even simpler to not have that boilerplate code at all).
Dunstabzugshaubitze@feddit.de 1 year ago
Access control and offering a sound interface.
You don’t need getters and setters if every attribute is public, but you might want to make sure attributes are accessed in a specific way or a change to an object has to trigger something, or the change has to wait until the object is done with something. Java just has tools to enforce a user of your objects to access its attributes through the methods you designed for that. It’s a safeguard against unintended side effects, to only open up inner workings of a class as littles as necessary.
In a language without something like private attributes you’d have to account for far more ways someone might mutate the state of objects created by your code, it opens you up to far more possible mistakes.
manapropos@lemmy.basedcount.com 1 year ago
I write Java for a living and the places I’ve worked have used Lombok to cut down on the boilerplate code
philm@programming.dev 1 year ago
My condolences, haha (I’m honestly not a big Java lover ^^).
manapropos@lemmy.basedcount.com 1 year ago
It’s not so bad. I’m just a lowly webdev and my work with Java is mostly just basic CRUD operations