Encapsulation unpythonic?

Ben Finney ben+python at benfinney.id.au
Sun Sep 1 19:32:16 EDT 2013


Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:

> […] programmers have been using the *principle* of encapsulation since
> before Grace Hopper was an admiral.

[…]
> Encapsulation and information hiding are distinct things -- you can
> have one without the other.

[…]
> One of the most obnoxious and annoying traits of OOP zealots,
> especially academics, is that they act as if programming did not exist
> before Java and C++, or if you're really lucky, Smalltalk. (Somehow
> they nearly always forget about Simula.)

Yes. That's something which has been pointed out to such people, even in
the Java community, for most (all?) of Java's history.

Here's a JavaWorld article from 2001, by a Java programmer, with the
clear title “Encapsulation is not information hiding”:

    Encapsulation refers to the bundling of data with the methods that
    operate on that data. Often that definition is misconstrued to mean
    that the data is somehow hidden.

    <URL:http://www.javaworld.com/javaworld/jw-05-2001/jw-0518-encapsulation.html>

(That site unfortunately slices up the article into many pages to
increase advertising hits and reader frustration, my apologies.)


One of the more annoying traits of humanity is that whatever context we
first encounter a term is disproportionately privileged, causing us to
irrationally dismiss better (more useful, more reasonable, more
pedagogically appropriate, more historically correct, etc.) definitions.

This thread is an excellent illustration that the field of programming
is no exception.

-- 
 \       Moriarty: “Forty thousand million billion dollars? That money |
  `\            must be worth a fortune!” —The Goon Show, _The Sale of |
_o__)                                                       Manhattan_ |
Ben Finney




More information about the Python-list mailing list