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.

typical OOP progaganda

also const correctness in languages that support that concept

Every IT profesor, ever

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

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

I am triggered

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

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
link
fedilink
21Y

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

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.7K Comments
  • Modlog