[Zope3-dev] keeping attributes abstract
Sidnei da Silva
sidnei at enfoldsystems.com
Thu Mar 9 07:27:58 EST 2006
On Thu, Mar 09, 2006 at 07:11:20AM -0500, Stephan Richter wrote:
| On Wednesday 08 March 2006 23:52, Sam Stainsby wrote:
| > No 'bar' attribute needed!
|
| I'll note that in the Python community we consider it an advantage of using
| attributes/properties versus accessor and mutator methods. This distinction
| between an attribute- versus method-centric object oriented programming
| language has been discussed in many articles.
|
| Note that we provide several other mechanisms to extend functionality; for
| example, the event system. Overall Zope (like most other Python code) is
| optimized to work with attributes/properties. We just like them too much! :-)
Not to mention that you can still use accessors/mutators with plain
attributes, and then store the actual value under a different name to
avoid the clash:
class FooX(Persistent):
implements(IFooB)
_bar = None
def setBar(self, bar):
doSomething()
self._bar = bar
def getBar(self):
doSomethingElse()
return self._bar
bar = property(getBar, setBar)
--
Sidnei da Silva
Enfold Systems, Inc.
http://enfoldsystems.com
More information about the Zope3-dev
mailing list