Usually, getters always return the value of a variable. I learned in my literature that access to fields is controlled by getters and setters. When I had my code rated by programmers, it was suddenly said that getters and setters violate object-oriented thinking.
So far, I have always set the output-statements in the method of a class that made changes to the object. However, if I want to change the way I make outputs (for example graphically or in a terminal), I would have to rewrite all classes. Therefore, I have considered doing the following: The output is no longer realized in the class, but the class provides methods that provide the values to be displayed. Another class is then created for display, which uses special getters to query the state of the object and display the data as it pleases. The getters are in the class that has this data. For example, I could have a "Human" object. The Human has amongst other things the variables lifeCurrent and lifeMax. These fields represent the health, if you set these values in relation. Another class called "Display" is now responsible for displaying the current health of a Human. So I would create a getter "getHealth" in the Human-Class that returns a list with lifeCurrent and lifeMax. the Display-class would have a function called health(Human). This function calls the getter from the Human and displays the values for the user of the program. Is it an accepted style to use getters like this?