I'm trying to improve my coding style as I go along, and want to know people's opinions about getters and setters.
Data should be private. Helps with encapsulation. Makes a lot of sense.
But if you have a class or struct that only exists to group together some related data, say as some sort of class within a class, are a bunch of trival getters and setters all that useful?
After thinking about it, I can see the argument that using getters and setters is always a good idea, because it can help with future debugging or expanding functionality of the class, if every variable access or change must be done through a function, you have an easy way to add logging or change the way it happens later, rather than digging through code for everywhere where those values were altered directly.
But I also read people on the internet moan about having a bunch of trivial getters and setters, and that objects should be designed around having an API of what actions you want to perform that result in the data being changed, rather than ever just changing the values directly. This makes a lot of sense too.
But sometimes I just want a simple class or struct that just stores some related data, so I guess in this case direct access probably makes the most sense and getters and setters should be avoided? Does it matter? Reduces overhead maybe, I don't know.
I know programmers love nothing more than a good moan, so if you have any opinions, feel free to have a whine and help me learn!