comp.lang.ada
 help / color / mirror / Atom feed
* usefulness of "data hiding"
@ 2009-01-16  0:51 Russ P.
  2009-01-16  1:08 ` Russ P.
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Russ P. @ 2009-01-16  0:51 UTC (permalink / raw)


Hello,

I thought some of you here might be interested in the following debate
I have been having on comp.lang.python with regard to the usefulness
of "data hiding" or "enforced encapsulation."

As many of you probably know, Python had no data hiding. It does not
allow you to declare anything "private," and everything is public by
default. (The convention is Python is to use a leading underscore to
identify a private _object or _function.) I suggested that a "private"
declaration could be useful if it could be implemented without
changing the language too drastically. Now, I can understand that
people just don't want to change the language that fundamentally, but
many Python folks over there insist that data hiding is just plain
useless in general. In fact, several people over there have argued
that Python is perfectly appropriate for even the largest safety-
critical systems.

I've tried to explain to them why data hiding can be useful, but I
just get back a lot of flak. If any of you are interested and have the
time to educate them, I'd be interested in your replies to the
following post, which was a reply to a post of mine. The link is

http://groups.google.com/group/comp.lang.python/browse_frm/thread/068bc54bca830c46?scoring=d&

Here is an excerpt:

The first OO languages (at least the second one - Smalltalk) used
data-hiding to clearly emphasize the "black box" nature of objects and
the use of messages as the main (only in the case of Smalltalk)
support
for control flow. Remember than by that time, lost of programs where
still mostly relying on *global* state changes. IOW, it has a strong
educative value then...

Following "OO" languages - mostly C++ and Java - kept this "rule" like
it was a sacred cow (but mostly forgot about the more important points
of 'everything is an object' and message-passing as main control
flow).
Then everyone started considering this as "fundamuntal", and here we
are
years later with one more cargo cult, when years of experience prove
that it's not - at least from a practical POV.

Once again, the important point is that there's a *clear* distinction
between interface and implementation, and that you *shouldn't* mess
with
implementation. But what, some people think programmers are stupid,
and
so they hire stupid programmers, so they need b&d languages to protect
stupid programmers from themselves - which just doesn't work, since
*nothing* is idiot-proof. Heck, how many Java "OO" programs with dumb
getter/setter pairs for _each and any_ attribute ?

> As I said before, enforced encapsulation may not be appropriate for
> every application, but it is definitely appropriate for some.

No. It is appropriate for dummy managers hiring dummy programmers. The
project's size and domain have nothing to do with it.

> Not
> every door needs a lock, but certainly some do.

You only need locks when you don't trust your neighbours.



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-01-19 16:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-16  0:51 usefulness of "data hiding" Russ P.
2009-01-16  1:08 ` Russ P.
2009-01-16  1:33 ` Adam Beneschan
2009-01-17 19:05   ` Marc A. Criley
2009-01-19 16:15     ` Adam Beneschan
2009-01-16  8:57 ` Dmitry A. Kazakov
2009-01-16 23:23   ` sjw
2009-01-17  8:53     ` Dmitry A. Kazakov
2009-01-18 13:07   ` Graham Stark
2009-01-18 14:17     ` Dmitry A. Kazakov
2009-01-16 17:21 ` Nicholas Collin Paul Gloucester

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox