I never use the package-level or protected access modifiers. I just find that I never need those levels of protection. To me, part of a class is either open or closed. Various degrees of "open" serve only to complicate my life, and my life is complicated enough.
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I don't like the fact that protected functions can be accessed by classes not in the inheritance hierarchy just because they happen to be in the same class.
I'm curious, though - what do you use package access for? I'm wondering if there's a separate, less object oriented programming style - perhaps whatever Ada was designed for - that would be oriented around packages instead.
Edit: I see in the other thread that you also use package access for testing only ... now I'm curious what other uses your coworkers have found for them?
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Originally posted by Warren Dew:
I think an argument might be made that with modern tools in an XP environment, modularity and code reuse is not as important as it once was.
On the other hand, I don't think protected accessors and mutators violate Ilya's rule that objects should tell each other what to do, rather than getting stuff from each other - the protected scope isn't usually for communicating with other objects, it's for communication within the object.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Don't get me started about those stupid light bulbs. |