Main Content

Who can use which access door?

Archive - Originally posted on "The Horse's Mouth" - 2006-09-21 11:49:54 - Graham Ellis

Anyone can come to our front door and ring the bell. It's then up to us whether we admit them to the house, or deal with them at the door. You can describe the front door as being public.

The side door through Lisa's office is more restricted, and whilst I and other members of the team can gain access through there, it's not how other visitors should gain entry. So the side door is protected

If anyone comes up to our place and happens to find we've left the door open ... walks in and knocks on the loo door when I'm in there, I'll probably be pretty unforgiving unless it's Lisa. Have I ever told you that Lisa and I are pretty close and come as a package?

And anyone who walks into the house, and straight into the toilet when someone's already using it is - well - invading their privacy

In Java, classes, methods and variables which might be accessible outside a class are marked public, protected, or private using a similar philosophy to I use on my doors. public is the widest access of all, and anything marked public will probably include checks to vet calls and usages and make sure they're valid. protected allows access from classes in the same directory or from subdirectories, so that it's generally available from team and family members but not from the wider world. package items (you don't specify the word package as it's the default) are only accessible to other classes in the same directory, and private items are only accessible from within the class in which they're defined.