• DarthFrodo@lemmy.world
    link
    fedilink
    arrow-up
    29
    ·
    1 year ago

    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.

    • PeWu
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Yeah, I need to force myself to do it, cuz it feels so slick and efficient and overall nice. Or am I just dumb and didn’t understand satire of this post.

    • HakFoo@lemmy.sdf.org
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      You can, but who ever does?

      I suppost that’s why some languages offer autogenerated minimal getter/setters, but that still seems like the same thing with extra steps.

    • PeWu
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Yeah, I need to force myself to do it, cuz it feels so slick and efficient and overall nice. Or am I just dumb and didn’t understand satire of this post.

    • PeWu
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Yeah, I need to force myself to do it, cuz it feels so slick and efficient and overall nice. Or am I just dumb and didn’t understand satire of this post.

    • PeWu
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Yeah, I need to force myself to do it, cuz it feels so slick and efficient and overall nice. Or am I just dumb and didn’t understand satire of this post.

  • alokir@lemmy.world
    link
    fedilink
    arrow-up
    8
    ·
    1 year ago

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

    • relevants@feddit.de
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      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

  • CanadaPlus@lemmy.sdf.org
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Real chads put everything in one namespace until they have to add numerals to functions like it’s a Reddit username. /s

  • watermelonsushi@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    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