I'm learning Java and the basics of OOP. Imagine I'm making a Person class. A person has of course a firstname and a lastname, that's why I declare two private variables in the Person class, being firstname and lastname. Both getting their initial value in the constructor. Now, how do you decide wether they both need a public getter and a setter, or only a getter and not a setter? Do you take this decission based on the kind of functionalities your application should have?
For example if you are building an application for the local sportsclub to keep track of their members (each member is a person object). Within the application there is a button to create a new member. if you push this button you have to fill in a firstname and a lastname and push the button 'create and add to club'. Behind the scenes there is a person object created. The application can show a list of all members and delete a member and thats all it can do.
Now there is no functionality like change firstname or lastname of a member. Could this be a reason why I should not have a setter for firstname and lastname? So if I created a member maked a typo in his firstname, I first have to delete him and then create him again without the typo. If the application had a button 'change name' I should need a setter or a method like changeName or something because I want to alter an already existing object.
Is this the correct mindset or has functionality nothing to do with encapsulation?
Ps. I know it's simple example but it's just to base my question on.
Thanks