Using getter/setter vs “tell, don't ask”?
问题 Tell, don't ask principle here is often pasted to me when I use getters or setters, and people tell me not to use them. The site clearly explains what I should and what I shouldn't do, but it doesn't really explain WHY I should tell, instead of asking. I find using getters and setters much more efficient, and I can do more with them. Imagine a class Warrior with attributes health and armor : class Warrior { unsigned int m_health; unsigned int m_armor; }; Now someone attacks my warrior with a