O'Reilly logo
  • Ervin Varga thinks this is interesting:

For that reason, when in doubt, favor the smallest possible scope for a variable: local to a specific loop, local to an individual routine, then private to a class, then protected, then package (if your programming language supports that), and global only as a last resort.


Cover of Code Complete, Second Edition


The order is not quite precise. Namely, package should come before protected, as protected implicitly includes the package visibility + adds the possibility for derived classes to see their parent's stuff.