Because you’re assuming foo won’t be renamed when it becomes a function. A function should start with a verb, say get_foo(), because just foo() tells me nothing about what the function does (or what to expect as output). If you make it a property, get_ is implicit.
So if the age is computed from the year of birth for example, it’s really e.g. thing.age or thing.get_age() - both of which are fine, but I’d pick the property version.
Or just thing.age() which is fine and is fairly obvious it will return the age of the thing. And that is what is done in most languages that dont have computed properties. get_ on a method really adds no value nor clarity to things. The only reason foo() is ambiguous is because it is a bad name - really just a place holder. Missing out the brackets here adds no value either, just makes it hard to tell that you are calling a function instead of just accessing a property.
Because you’re assuming
foo
won’t be renamed when it becomes a function. A function should start with a verb, sayget_foo()
, because justfoo()
tells me nothing about what the function does (or what to expect as output). If you make it a property,get_
is implicit.So if the age is computed from the year of birth for example, it’s really e.g.
thing.age
orthing.get_age()
- both of which are fine, but I’d pick the property version.Or just
thing.age()
which is fine and is fairly obvious it will return the age of the thing. And that is what is done in most languages that dont have computed properties.get_
on a method really adds no value nor clarity to things. The only reasonfoo()
is ambiguous is because it is a bad name - really just a place holder. Missing out the brackets here adds no value either, just makes it hard to tell that you are calling a function instead of just accessing a property.