GetHealth and SetHealth are bad. Monsters don't just walk up to you and perform damage calculations for you and then suddenly your health is a different number. Monsters also don't need to know your health.
GetName but not SetName is better. Someone else needs to know your name, so they ask you.
SetPosition but not GetPosition is better. The server decides where you are, and tells you. It doesn't ask you where you are, because it already knows and it doesn't trust you.
Whether or not getters and setters are bad is contextual, they're not all-around bad, just commonly misused, and it is easy to simplify an explanation and say they're bad.
In general, I follow:
-Setters should only be available to those in charge of you (e.g. a server)
-Getters should only be available to those who need to know (e.g. the UI)
-Getters and Setters should always be available to deriving classes who need to customize functionality
-Getters and Setters should be designed in a way that makes them as flexible as possible as to what implementation is used (e.g. storing a string, asking a lib, sending a network request, opening a file...)
And, they din't even have to 'look' like getters and setters. They also don't have to have 'get' or 'set' in their name:
1 2
|
void Name(const std::string &name);
std::string Name();
|
But the name is your choice.