Implementing class attribute access methods via pseudo-functi on o verloading.

Diez B. Roggisch deetsNOSPAM at web.de
Mon Oct 25 08:23:29 EDT 2004


> It's interesting to note that you prefer code like: theProblem.title =
> "The Title"
> 
> However, I wonder if people coming from the Java/C++ world prefer:
> theProblem.title( "The Title" )
> 
> Obviously the first version is less typing! However, the second version
> might feel more natural to Java/C++ programmers.  Just an observation!
>

The reason java introduced the bean-convention with set*/get* methods (and
maybe has/is on boolean values) was to allow to introduce a property-like
concept in java - as its missed at syntactical level - with the assumption
beenig that a get/set paired name is an actual property. There are apis for
that, and e.g. gui-editors use it it create dialogs for configuring
controls.

So what you assume looking more natural and less awkward to java-people is
an akward convention introduced to circumvent missing language capabilities
- at least IMHO :)

C# OTH has properties built in, as well as VB - and the make code look
definitely nicer (apart from VBs ridiculous "let" statement and the general
pains of that language...)


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list