object.setobject(object.getobject().object).to_object()

61 points · 11 comments · view on lemmy.world

11 Comments

DarthFrodo@lemmy.world · 21 pts · 3y (2 replies)

The neat thing is, you can add stuff like range checks and logging for getters and setters without changing every call. Separation of concerns is also vital in larger projects.

hairinmybellybutt@lemmy.world · 20 pts · 3y

typical OOP progaganda

jazz@lemm.ee · 6 pts · 3y

also const correctness in languages that support that concept

alokir@lemmy.world · 6 pts · 3y (1 reply)

Wait until you hear about the concept of properties in languages like Javascript, C#, Kotlin and many others.

relevants@feddit.de · 3 pts · 3y

At least for Kotlin it's literally just syntactic sugar for getter and setter methods. I really like them, don't get me wrong, but it's just the bottom approach masquerading as the top approach

metarmask@sh.itjust.works · 4 pts · 3y

That's not a new way to change data, it's reading it.

redcalcium@c.calciumlabs.com · 2 pts · 3y

I'm convinced that Java programmers need to write setters and getters to meet their KPI target.

lntl@lemmy.sdf.org · 2 pts · 3y

I am triggered

watermelonsushi@lemmy.fmhy.ml · 1 pts · 3y

I love dart's approach to getter and setter methods... They let you define methods labelled explicitly as "get" or "set" methods that you can call without writing the parentheses. So the call looks like accessing a member variable, but internally it can handle additional functionality like logging or validation or whatever you want. So the syntax would look like the first example in the meme, but with all the benefits of the second example. I wish more languages would incorporate this

apprehentice@lemmy.enchanted.social · 1 pts · 2y

Imagine not using a language with setters and getter built in lol

bi_tux@lemmy.world · -2 pts · 3y

Every IT profesor, ever