[Tutor] tkinter events: <B1-Motion>

Alan Gauld alan.gauld at btinternet.com
Mon Aug 28 22:23:16 CEST 2006

I just found this message (because Mike posted the tinyurl....)
and couldn't resist responding...

"Zsiros Levente" <zslevi at sch.bme.hu> wrote
> If we're talking about data hiding, let me ask: why Python doesn't
> implement data hiding (I mean 'private' and 'protected')? I consider 
> it
> a very important OOP feature, because that makes OOP different from
> structural programming.

This is a hot-button of mine...

Why do you think data hiding is important for OOP?
And in particular why do you think it differentiates
OOP from structural techniques?

Data Hiding was not part of the early OOP languages
(Simula, Lisp and the first Smalltalks) it was introduced
first by Smalltalk in (Smalltalk 74 I think) and it was only
when C++ came out that all the public/private nonsense
appeared, followed by protected in C++ v2.0

Many OOP languages do not support data hiding, it is
not necessary for OOP. Data hiding is supported in many
structual languages like the Modula family and ADA.,
but they are not OOP. (The concept was introduced by
David Parnas in 1972 - long before OOP became popular)

The point being that Data hiding is an orthogonal issue
to OOP which relies on encapsulation and polymorphism.
- Encapsulation(*) is the ability to treat the data and methods
  as a single entity - an object.
- Polymorphism is the ability for different objects supporting
  the same protocol to react in different ways to the same

Inheritance is an optional extra but is usually required to
implement polymorphism...

(*)Some texts get data hiding and encapsulation confused.
Encapsulation as originally applied to OOP is about joining
the data and function together - so fundamental to OOP that
some folks forget its even there as a feature!

Data hiding is about making data available through an API.
That API could be an object's protocol or it could be a
module interface. It's usually a good thing to do, but not
a requirement of OOP.

Rant over,

If anyone wants a more academic review oif the differences
between data hiding (or more correctly, information hiding),
encapsulation and abstraction see this white paper:


by Ed Berard.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list