Encapsulation vs Extensibility
- From: "Anthony Paul" <anthonypaulo@xxxxxxxxx>
- Date: 12 Jan 2007 14:06:08 -0800
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
.
- Follow-Ups:
- Re: Encapsulation vs Extensibility
- From: Robert Martin
- Re: Encapsulation vs Extensibility
- From: Robert Martin
- Re: Encapsulation vs Extensibility
- From: Sargon the Flood Stricken
- Re: Encapsulation vs Extensibility
- From: Mark Nicholls
- Re: Encapsulation vs Extensibility
- From: S Perryman
- Re: Encapsulation vs Extensibility
- From: H. S. Lahman
- Re: Encapsulation vs Extensibility
- From: Dmitry A. Kazakov
- Re: Encapsulation vs Extensibility
- From: Daniel T.
- Re: Encapsulation vs Extensibility
- Prev by Date: Re: Delta
- Next by Date: Re: Simples Rules make creating Big Balls of Mud impossible.
- Previous by thread: MVC design advice for a simple GUI app.
- Next by thread: Re: Encapsulation vs Extensibility
- Index(es):
Relevant Pages
|