python development practices?
James_Althoff at i2.com
James_Althoff at i2.com
Wed Oct 31 15:20:36 EST 2001
Cliff Wells wrote:
>I tend to use this method as well. My feeling is that keeping data
>attributes private (by convention) helps keep classes as "black boxes".
This
>allows the internal implementation of the class to change at will as long
as
>the get/set methods provide the same interface. This allows things such
as
>changing a list to a dictionary without fear that this will break some
>outside code.
Absolutely! The ability to change a class implementation whilst preserving
backwards compatibility via the safety net of method access has saved the
derriere on numerous occasions. (The very notion of hard-coded access to
instance variables strewn about in random pieces of code in a large system
just flat-out gives me the willies. For me, the really important thing is
actually *to buy into* the idea of encapsulation).
Jim
More information about the Python-list
mailing list