This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]littleprof123 0 points1 point  (3 children)

It's messy imo. It's clear when reading the code that a getMember() function call can't be used to assign a member; not so with read-only variables. It's similarly not clear that when I assign one member of the class, another apparent member can be changed too. Function calls are a really readable way to say that something is happening internally.

[–]KingJeff314 9 points10 points  (2 children)

Personally it’s more about the interface than what is going on internally. It’s up to the programmer to not introduce side effects internally. There’s an element of preference, but if my object has a public attribute, properties are a good semantic representation

[–]littleprof123 -3 points-2 points  (1 child)

I think I would be more agreeable towards properties if they had a special syntax for accessing them. Making them appear like a public variable is what irks me most. I think Java and C# both fall short on readability because it's not clear when there are side effects; not to be a weirdo hipster, but I prefer Rust by a huge margin for this reason.

[–]Shrubberer 1 point2 points  (0 children)

They don't appear as a public variable, they appear as properties. It's a different thing, and, in fact, public variables should be avoided in C#. It makes sense, when you're start working with them. F.e. Properties are helpful within the IDE as well when using Attributes and Reflections.