Re: Encapsulation vs Extensibility



Anthony Paul wrote:

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.

It is indeed so in a prog lang that has inferior access control to
type properties.


Sometimes I'd be able to work around it, but workarounds in my humble
opinion are just plain ugly

Often the case in a prog lang that has inferior access control to
type properties.


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.

A strong feature of OO is extensibility.
But who is 'advocating' the use of private 'so much' ??


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.

I believe this is an example of a concept known as *opinion* .


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.)

And the use of the 'private' construct in OO relates to the rigour of CS
how exactly ??


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.

How very true.
The Halting problem : will my program halt ??
Nah, all Turing et al could say was : some do, some don't.


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?

What is the 'scientific backing' that determines whether properties of a
type should be made public or private ??


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.

You'll be a happy camper when you've overcome your ignorance of how
access control is implemented in less than inferior prog langs.
Probably couuple with not using prog langs having inferior access control
schemes.


Regards,
Steven Perryman
.



Relevant Pages

  • Encapsulation vs Extensibility
    ... into the 'private' modifier. ... stopped me from extending the functionality of the class to my liking. ... method being applied in a true scientific field such as physics that it ... 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)