Why a getter doesn't need a "get" prefix


Never use a get prefix for getters.


Usually we consider member functions to be getters if they simply return a reference or pointer to a private member, just for the sake of data incapsulation. Such functions don’t do anything really, they have no payload.

So, there is nothing requiring a “get” verb to describe its meaning. The getter is just an alias of a member. The “get” prefix is only required when a function does a real data transformation or computation, for instance, getLastTick() or getFullUserName(). But it is even better here to replace “get” by something more meaningful, extractLastTick() and buildFullUserName().

Related posts: