Possible Duplicate:
Why use getters and setters?
It seems to me like a major hassle to write accessor and mutator methods, particularly when dealing with very simple attributes. Why should I bother using them?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer mainly depends on what are you writing code for and how much you trust yourself if working alone:
frienddirective that allows fine grain encapsulation without the bother of having setters and getters (even if it encourages coupling so there are two different schools of thinking here)