Not Using Protected Keyword

OK, I admit it I’m a simpleton when it comes to scoping things in Java. Out of all four possible keywords for scoping access I manage to use two:

  • public
  • private

I realize there’s probably a good reason where I’d want to use protected or default scope, but I just haven’t run across one. I find sticking to private and public simplifies my designs. It is very clear whether the variable or method was supposed to be encapsulated by the class. Since I don’t do APIs if I need access then it generally might as well be public.

When I do run across a protected or default in example code I often wonder if there was an explicit reason for it. It turns out that IBM’s RAD 6.0 writes all its JSF backing bean methods as protected scope, though I still don’t get why.

Of course I may also just be missing some blindingly obvious OO concept that makes protected really cool.