Encapsulation vs Extensibility



Hello everyone,

I see a lot written about how one should strive towards keeping as much
of a class's fields/methods private and only exposing essential
functionality. However, when I first transitioned to OO many moons ago
and started fiddling with inheritence and extending components, I ran
into the 'private' modifier. Each encounter was a pain seeing that it
stopped me from extending the functionality of the class to my liking.
Sometimes I'd be able to work around it, but workarounds in my humble
opinion are just plain ugly, and though I would pat myself on the back
each time I managed the impossible, I couldn't shake the feeling that
something was wrong. While I can see that the 'private' modifier has
its uses, I'm puzzled as to why it's advocated so much given that one
of the strong points of OO is extensibility. I sniff around and there
are other articles written bashing the use of 'private' and how we
should make everything public and live happily ever after.

One camp says this, another camp says that.

There seems to be such a high degree of rigour and the scientific
method being applied in a true scientific field such as physics that it
becomes painfully obvious to me that computer science is nothing more
than a pseudo/cargo-cult science (in honor of one of my true idols in
life, the late Richard Feynman.)

Ernest Rutherford once said ""The only posible conclusion the social
sciences can draw is: some do, some don't." It seems to me that the
same can be said about computer science.

Should I make my fields private? Should I make them public? Should we
bother posing such questions knowing that the answer will be nothing
more than public opinion without any scientific backing?

Excuse my cynicism people... I've been holding this in for the past 20
years. I will be a truly happy camper the day I see some science in
computer science.

Anthony

.



Relevant Pages

  • Re: Encapsulation vs Extensibility
    ... into the 'private' modifier. ... stopped me from extending the functionality of the class to my liking. ... type properties. ... becomes painfully obvious to me that computer science is nothing more ...
    (comp.object)
  • Re: Encapsulation vs Extensibility
    ... into the 'private' modifier. ... opinion are just plain ugly, and though I would pat myself on the back ... becomes painfully obvious to me that computer science is nothing more ...
    (comp.object)
  • Re: Need help in choosing the project
    ... I am doing my Master of Engineeing in Computer Science in a private ... college, chennai. ...
    (comp.programming)
  • Need help in choosing the project
    ... I am doing my Master of Engineeing in Computer Science in a private ... college, chennai. ...
    (comp.programming)
  • Re: Desirable Usage of Fortran Modules
    ... > global-variable functionality of modules. ... > that the global variables are private to the module. ... particular nature of sub, one can't write a fully generalized black-box ...
    (comp.lang.fortran)