ethz-asl / programming_guidelines

This repository contains style-guides, discussions, eclipse/emacs auto-formatter for commonly used programming languages
139 stars 38 forks source link

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

Closed simonlynen closed 11 years ago

simonlynen commented 11 years ago

Should this be called differently, something along these lines?

getRef() ref()

stephanemagnenat commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago
simonlynen commented 11 years ago

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

furgalep commented 11 years ago

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

How about

getVariableRef()

it is better than getVariableMut()

simonlynen commented 11 years ago

Good lets go for: getVariableRef()