Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

The terms get/set must be used where an attribute is accessed directly. What if references are returned? #5

Closed
simonlynen opened this issue May 6, 2013 · 6 comments

Comments

@simonlynen
Copy link
Contributor

Should this be called differently, something along these lines?

getRef()
ref()

@stephanemagnenat
Copy link

As with the underscore, I am worried about over-verbose style. There are some cases when a getter would better use a different naming, such as isEmpty() instead of getEmptyStatus().

@furgalep
Copy link

Google uses something like getVariableMutable(), which is more of a language-independent way to say it. I'm not against verbosity in general (this is probably obvious to everyone). I haven't been using get/set religiously up to this point but I wouldn't mind starting now.

I do agree, however, that it is nicer to have meaningful names for things. I would advocate isEmpty() over getEmptyStatus().

Now that I'm thinking, getVariableMutable() is nice because it is really clear what is happening.

Can anyone convince me otherwise?

@HannesSommer
Copy link
Contributor

  • "is", "has", .. should be legitimate (if not required prefixes) for boolean getters. Is seems to me quite common and handy (except for reflections over getters :). but - in that case - luckily there is non for c++)
  • The Mutable postfix seems to me a good idea. But I would rather like a shorter version and something third to getters and setters: getXXXMutable reads like a special case of a getter, which of course they are. But in my opinion they are equally a special case of a setter. So they require a neutral word. But as I'm not a English native I don't feel able to find the right verb. In my "private language" I usually call them "accessors" (because they give read and write access) and sometimes write accessXXX. What do you guys think of that prefix / verb? Can you think of a better one?

@simonlynen
Copy link
Contributor Author

@furgalep Paul can you think of a proper english term for the reference getters?

@furgalep
Copy link

furgalep commented Jun 8, 2013

I just looked up the synonyms for mutable and nothing is jumping out at me.

How about

getVariableRef()

it is better than getVariableMut()

@simonlynen
Copy link
Contributor Author

Good lets go for: getVariableRef()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants