J
Jeremy S.
Just getting into OOP here...
I remember reading somewhere that having protected and/or internal member
variables is to generally be avoided or potentially a "bad thing" because
having such members violates the OOP principle of encapsulation. The way it
was presented was something like, "having a protected member implies a high
degree of trust between the base class and any derived classes - because the
derived classes have unrestricted or uncontrolled access to the protected
variable."
I now have a situation where I have a few member variables and methods that
need to be called by derived classes "as is" - so no apparent need [apparent
to me anyway] to make them abstract or virtual as the derived classes have
no need to modify their behavior (speaking of the methods in particular).
This seems to be a perfectly reasonable use of 'protected' scope. Am I
missing something? Or would most of you just shrug this off and say "very
well then."
Thanks.
I remember reading somewhere that having protected and/or internal member
variables is to generally be avoided or potentially a "bad thing" because
having such members violates the OOP principle of encapsulation. The way it
was presented was something like, "having a protected member implies a high
degree of trust between the base class and any derived classes - because the
derived classes have unrestricted or uncontrolled access to the protected
variable."
I now have a situation where I have a few member variables and methods that
need to be called by derived classes "as is" - so no apparent need [apparent
to me anyway] to make them abstract or virtual as the derived classes have
no need to modify their behavior (speaking of the methods in particular).
This seems to be a perfectly reasonable use of 'protected' scope. Am I
missing something? Or would most of you just shrug this off and say "very
well then."
Thanks.