View Single Post
Old 08-02-2012, 07:01 PM   PM User | #12
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by tomjas View Post
Ok guys.
Thanks for explanations. So as far as I understand: along with good programming practice I should put private/protected for variables as well as for methods which process these variables, and write separate public method which returns result of these methods (their process - calculations, changing, etc.)? In other words - methods in class should be private/protected so no one can interfere from outside. For these methods should by public methods which returns their result?
No that's not right. The setters and getters should be public if the property can be accessed from outside of this class. You don't need to specify multiple write methods for a single property, just the one is sufficient. If you make everything private or protected, than this class becomes useless outside of itself since you cannot call anything on the object outside of it.
Fou-Lu is offline   Reply With Quote