Skip to main content
3 events
when toggle format what by license comment
Aug 5, 2011 at 18:00 comment added Aaronaught How about an analogy: A private/protected access modifier is like a condom. You don't have to use one, but if you're not going to, then you'd better be damn sure about your timing and your partner(s). It will not prevent a malicious act, and might not even work every time, but it will definitely lower the risks from carelessness, and do so far more effectively than saying "please be careful". Oh, and if you have one, but don't use it, then don't expect any sympathy from me.
Aug 5, 2011 at 17:49 comment added Aaronaught @Simon: We need to clarify "ignorance" here. Prefixing a method with _ states the contract, but doesn't enforce it. That may make it hard to be ignorant of the contract, but it does not make it hard to break the contract, especially not when compared with tedious and often restrictive methods like Reflection. A convention says, "you shouldn't break this". An access modifier says, "you can't break this". I am not trying to say that one approach is better than the other - they are both fine depending on your philosophy, but they are nevertheless very different approaches.
Aug 5, 2011 at 14:37 history answered Aaronaught CC BY-SA 3.0