0
Are getters and setters evil???
So I was talking to someone today and they were telling me that getters and setters are usually to be avoided if possible because it contradicts the principal of oop which is to hide implementation of objects which I get. Iām just curious as to how you guys go about doing that. Iām kind of stuck as to how to put this principal into practice.
3 Answers
+ 4
its called encapsulation its to keep your class fields private
+ 3
0
ćļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć ahhhh I think I follow. So are saying that get methods and set methods are ok sometimes if the name is soecific but caution is needed because it could possibly cause a sode effect where a child is modifying the parents attributes?