Tkinter callback arguments

Alf P. Steinbach alfps at start.no
Mon Nov 2 16:51:36 CET 2009


* Diez B. Roggisch:
>> Your comment about "computed" makes it more clear what that's all about.
>> Also Bertrand Meyer (Eiffel language creator) had idea like that, he
>> called it "referential transparency". But I think when Python has this
>> nice property mechanism, why do people change direct data attributes into
>> properties and not the other way around or not at all, I mean using only
>> properties for logical
>> data attributes  --  e.g. assuring correctness first via read-only
>> property?
> 
> I fail to see where read-only-ness of an attribute is a priori more correct
> than having modifyable attributes.

No, I didn't mean that it is more correct to have an attribute as read-only. I 
meant that letting a logical data attribute start out as a read only property 
can help to ensure correctness. For example, consider two rectangle classes R1 
and R2, where R2 might be a successor to R1, at some point in system evolution 
replacing R1. R1 has logical data members left, top, width and height, and R2 
has logical data members left, top, right and bottom. With R1 direct changes of 
left and top keeps the rectangle's size (since that size is specified by width 
and height), while with R2 it changes the rectangle's size. R1 is implemented 
with logical data members as directly exposed data attributes. Some code in the 
system deals only with R1 objects and for convenience or efficiency or whatever 
uses direct modification instead of set_position method. Due to new requirements 
it instead has to deal with R2 objects, with same methods. But due to the direct 
modification of object state it now changes the rectangle sizes, but at first 
it's not noticed since the attempted rectangle position changes are very small. 
People get upset. The bug is fixed. Time has been wasted.


> Again, it's an assumption of a future
> use or constraint that is most of the times simply not correct or
> relevant - at the price for more typing, and computational overhead.

Hm, not sure.


Cheers,

- Alf



More information about the Python-list mailing list