[Edu-sig] Re: Best approach to teaching OOP and graphics
Dethe Elza
delza at livingcode.org
Fri Apr 1 03:05:20 CEST 2005
On 31-Mar-05, at 3:53 PM, Beni Cherniavsky wrote:
>> There are still times when you don't want to expose attributes
>> directly, but getters and setters don't help you there either. For
>> example, if both myObj.x and myObj.y must be changed in synch to stay
>> valid, then they should be set via myObj.setXandY(x,y) not myObj.x =
>> newX, myObj.y = newY. But this is a design problem not a language
>> problem.
> myObj.xy = (x, y)
>
> Rule of thumb: use tuples where you typically change all members
> together. Use mutable objects (lists/dicts/objects with attrs) where
> you frequently change individual members.
Good point. Python solves another design problem. Is there anything
it can't do?
--Dethe
I can't watch television without praying for nuclear holocaust. --Bill
Hicks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2488 bytes
Desc: not available
Url : http://mail.python.org/pipermail/edu-sig/attachments/20050331/153c0f9b/smime.bin
More information about the Edu-sig
mailing list