DEVELOPERS: Terminology poll! I am interested in your understanding of the word “property,” regardless of programming language.
-
@inthehands I think the bigger issue/question is that properties are supposed to be idempotent. That's what makes it a property to me.
-
@helge
Wow, that’s an interpretation of the word that’s new to me! -
@inthehands Interesting. A property to me should have no meaningful side effects. I've seen people doing KVC properties and wondering when they run into issues because a property setter also set like 10 other unrelated things.
-
The main thing I’m learning from this poll is that words do not actually have meanings
-
@helge
Does this mean that “to change a property” or “set a property” is ill-defined in your lexicon? -
@inthehands No, the operation should just be idempotent, i.e. have no side effects. Like this:
```
final class Mehr {
var _x = 0
var y = 0var x: Int {
set {
_x = newValue
y += 1
}
get { _x }
}
}
```
I wouldn't consider `x` a "property" here because calling it 10 times will have side effects unrelated to it. This would be fine:
```
final class Meer {
var _x = 0var x: Int {
set { _x = newValue * 2 }
get { _x / 2 }
}
}
``` -
@inthehands C# is pretty specific about calling the instance variable a "field" and something like
public String color { get; set; }
a "property".Outside of C# I think of properties, fields, and instance variables as synonymous.
-
@helge
Ah, no side effects •other than the property state itself• — yes, agreed! -
@inthehands Essentially this:
```
thing.a = 5
thing.a = 5
thing.a = 5
```
should modify nothing but `a`. But those could also be composed values, the key thing is that you can assign as often as you want w/o side effects.
That's what makes a property to me, not whether it is computed or stored. -
@yoshimcf
It varies quite a lot by lang!Swift has a definition that’s as close to C#’s as not. (It has no surface-visible ivars at all; you can only define getters and setters, and “stored properties” have implied but invisible ivars.)
Javascript freely muddles the get/set and ivar meanings.
Thus the poll: I want to see whether it’s a widely understood term. It seems not to be, not without lots of hand-waving anyway.
-
@helge
Yeah, then in that case, I think our personal definitions are very close. -
DEVELOPERS: We need technical jargon because it is precise and it allows us to communicate!
ALSO DEVELOPERS: We do not agree on the meanings of even the most common words…ever, basically
-
@inthehands “Words are useless, especially sentences. They don't stand for anything. How could they explain how I feel?" - Madonna but obvs written by Björk
-
Hmm...please give an example of a developer jargon term that is very, very ambiguous.
-
Oliphantom Menacereplied to Paul Cantrell last edited by
@inthehands I usually think of getters and setters as "accessors" but it turns out those are essentially a kind of property.
-
@ashwin
Well, see the poll results.Or if that’s not satisfying, oh…”port”
-
FOLLOW-UP: Suppose I alter the code. Now it looks like this:
private colorHexCode: String
public getColor() { return self.colorHexCode }
public setColor(color: String) { self.colorHexCode = color }Does this object have a “color” property?
-
FOLLOW-UP #2: In the context of your day-to-day programming, does “attribute” mean the same thing as “property” to you?
-
@inthehands need an "i dunno i'd probably try to work out whether my audience cared" option
-
Rachael Ludwickreplied to Paul Cantrell last edited by
@inthehands probably would depend on language and the common conventions of that language community which, uh, maybe not great.