News for hackers. Stuff that matters.
Re:Avoid getters and setters whenever possible by frou_dh on Thursday March 22, 2018 @07:15AM (#16647584)
If one is commanding an object to set a private data field which one somehow knows the name of, then it's not an object that is being dealt with, just a procedural programming data bag.

Setter methods are 95% the same as direct mutation of encapsulated state. It degrades the concept of objects being smart independent entities.

Re:Avoid getters and setters whenever possible by rhapsodic on Thursday March 22, 2018 @07:45AM (#16647733)
> It degrades the concept of objects being smart independent entities.

"Smart independent entities"? That's a new one on me. What does that mean?

Re:Avoid getters and setters whenever possible by frou_dh on Thursday March 22, 2018 @08:13AM (#16647896)
An object graph operating more like a network of tiny special-purpose computers with I/O (messages/method-calls). Rather than occupants that are conscious of being not much more than rectangles in a single memoryspace. Alan Kay also made analogies with cell biology.
Re:Avoid getters and setters whenever possible by spdionis on Thursday March 22, 2018 @07:44AM (#16647718)
Getters/setters vs public properties has nothing to do with encapsulation. Obviously not all properties are public/have getters and setters.
Re:Avoid getters and setters whenever possible by frou_dh on Thursday March 22, 2018 @07:54AM (#16647776)
I didn't mention getters at all. I agree that encapsulation status remains constant in the presence of either setter methods or direct mutation, i.e. broken.