Say I have a C++ class that holds an array.
A member function of this class for example, could be to return the value at a certain index. I'm confident this would be considered a getter method.
However, how would you classify a similar function that instead simply returns a boolean based on whether or not the value exists in the array?
This function is 'getting' something but not necessarily a value from a member of the class. Would this still be considered a getter method?
Does it really matter? Consider this interface:
struct Adder {
Adder(int a,int b);
int get_sum();
};
for the user of this class it should not matter at all whether implementation is this:
struct Adder {
Adder(int a,int b) : a(a),b(b) {}
int get_sum() { return a+b; }
private:
int a,b;
};
or this:
struct Adder {
Adder(int a,int b) : c(a+b) {}
int get_sum() { return c; }
private:
int c;
};
The second does return a member and according to your definition it would be a "getter" method. The first does not, but does it mean that it is not a true "getter" method? Whether the method actually returns a member or something else is an implementation detail and should not matter to the caller, nor should it affect the name you give to the method.