Re: Encapsulation vs Extensibility
- From: S Perryman <q@xxxxx>
- Date: Sat, 13 Jan 2007 23:19:12 +0000
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
.
- Follow-Ups:
- Re: Encapsulation vs Extensibility
- From: Mark Nicholls
- Re: Encapsulation vs Extensibility
- References:
- Encapsulation vs Extensibility
- From: Anthony Paul
- Encapsulation vs Extensibility
- Prev by Date: Re: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"
- Next by Date: Re: Encapsulation vs Extensibility
- Previous by thread: Re: Encapsulation vs Extensibility
- Next by thread: Re: Encapsulation vs Extensibility
- Index(es):
Relevant Pages
|