Nice post!
From my point of view, the main concern of classes is joining behavior and data into an encapsulated piece of code.
This split the code into cohesive pieces and decreases coupling. Two good properties of maintainable code.
The caller doesn't know how the behavior is implemented it only cares about what the method does.
Creating a class as a bag of data and expose data through getters and setters is not object-oriented since it delegates the manipulation of the data to the caller. That is procedural code using classes.
My suggestion for making your final example a little more OOP is:
MoveSystem.out.println from Person class to caller class (Main).
Remove all getters from Person class. (Nobody uses them and nobody should)
Implement to_string method instead of printInfo
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice post!
From my point of view, the main concern of classes is joining behavior and data into an encapsulated piece of code.
This split the code into cohesive pieces and decreases coupling. Two good properties of maintainable code.
The caller doesn't know how the behavior is implemented it only cares about what the method does.
Creating a class as a bag of data and expose data through getters and setters is not object-oriented since it delegates the manipulation of the data to the caller. That is procedural code using classes.
My suggestion for making your final example a little more OOP is:
Move
System.out.println
from Person class to caller class (Main).Remove all getters from Person class. (Nobody uses them and nobody should)
Implement
to_string
method instead of printInfo