[Tutor] Properties of an object

spir denis.spir at free.fr
Fri Jan 30 21:10:13 CET 2009


Le Fri, 30 Jan 2009 19:05:40 -0000,
"Alan Gauld" <alan.gauld at btinternet.com> a écrit :

> "spir" <denis.spir at free.fr> wrote
> 
> > There is no real native support for ordinary OOP in python, meaning
> > as is done in most other languages, or according to the theory.
> 
> I have to disagree. I think you are confusing OOP with C++ and Java.
> The early OOP languages had a variety of approaches to this. Several
> took the same approach as Python and ignored visibility of attributes
> (Lisp & Object Pascal being obvious examples), others took the
> other extreme of making all data "private" with no way to access
> it other than via methods (Smalltalk being the prime example here)
> 
> The common terms for controlling access (private/public, and later
> protected) didn't come along until C++ showed up in the mid 80's
> 
> And the theory of OOP is much less concerned about data hiding
> (a technique championed by David Parnas at around the same
> time OOP was being developed) than it is about the idea of
> independant objects encapsulating data and functions within
> a single entity or capsule. The most common theoretical models
> were of each object being a separate process communicating
> over message streams. Polymorphism was identified as a key
> feature early on but even the idea of inheritance was later. Data
> hiding was an orthogonaslconcept that happened to fit quite well
> with the ideas of OOP but was not intrinisic to it.
> 
> So Python fits very well with basic OOP theory and practice,
> its just quite different to C== and Java practice. But I would
> strongly argue that neither C++ nor Java are particularly good
> OOP languages - they have been compromised to facilitate
> familiarity for most developers. Thats a very pragmatic approach
> if you want to get a language adopted and has worked well for
> both, but it doesn't mean they are very pure from an OOP standpoint!
[...more...]

I agree with you, Alan (including what you have written in the part I cut). I also share your point of view about C++ and Java. And I was *not* speaking from their standpoint (correct?), nore from any other specific language -- except maybe unconsciously from objective Pascal variants. I should have been more precise in the lines you quote above.

[Also, if ever I criticise some point, it's always due a need of understanding. Sometimes it's hard to get a useful reply, and I may take the devil's advocate position in order to learn what actually hides where my eyes do not yet see.]

I was not thinking at data hiding or protection, rather at object structure (or behaviour) specification. First, to the human -- and alse to the machine. What I mean is that, as it is possible to remove/change/add any feature of an object, at any time and from any place, there is no real object specification; not even by class: not only an object (rather: an instance) can evolve independently, but a class itself, beeing an object, can change too. I do *not* mean that this is bad in any sense. Rather I do mean that this can trouble, as it has long troubled me when I first discovered python, especially combined with next point.

In a rather consistent approach, Python does not provide any standard way to simply define/describe/structure an object -- or a class. This would be +/- absurd, as anything can change at any time. This participates to trouble; after all, OO is well about defining objects that represent model components, aspects, agents, their behaviour, their relationships. No? I may be wrong, still for me *this* is OO fondamental. Note that this is different from gentleman's agreement on not misusing a provided object structure or interface. This is information.
Think kind of definition still seems to be needed, so that several formal or informal ways live in the python community to remedy that, from doc/comment practices to attribute "introduction" in __init__, etc... All of these carry no real language semantics, instead for me they fulfill a human relevant semantic need -- that I was missing, and still miss.

denis

------
la vida e estranya


More information about the Tutor mailing list