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.

4th Jul 2018, 2:58 AM
Haon1919
Haon1919 - avatar
3 Answers
+ 4
its called encapsulation its to keep your class fields private
4th Jul 2018, 6:07 AM
D_Stark
D_Stark - avatar
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?
4th Jul 2018, 3:40 AM
Haon1919
Haon1919 - avatar