Python Productivity over C++ (Encapsulation)

Martijn Faassen m.faassen at vet.uu.nl
Thu Jun 15 18:27:58 EDT 2000


Hung Jung Lu <hungjunglu at hotmail.com> wrote:
[snip]
> One of the biggest lies in modern computer language theory is that 
> encapsulation is there for a good technical reason.
[snip]
> Encapsulation is not there for any technical reason.

Encapsulation is necessary if you want abstraction. There is no strictly
*technical* reason for wanting abstraction; but source is not written
for the computer alone. Source is written at least as much for other
humans. And humans want to be able to forget about details so they
can focus on the problem at hand.

By encapsulating the details (into a function, module or class), you can
use the functionality without having to think or worry about the details.
You don't care about the implementation. That's abstracted, encapsulated.

So there's a human reason. Or a software engineering reason, at least.

[snip]
> If one day Java becomes a legacy language and loses the battle against 
> open-source languages like Python, it's exactly because people are waking up 
> and liberating themselves from the corporate handcuffs.

This is perhaps a slightly different issue. The difference is subtle.
Python does not have as many tools for 'enforcing' encapsulation, just like
it doesn't have so many tools for enforcing type-safety. Python trusts
the programmer more in both cases.

That doesn't mean a Python programmer should forget about encapsulation.
Python programmers care about interfaces, and if you want to have abstract
interfaces, you'll have to stay away from implementation details, and
respect the encapsulations. But if you know what you're doing and you
really want it, Python doesn't get in your way. So you can't get painted
into a corner as easily with Python.

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list