On 2005 Jan 20, at 02:47, Skip Montanaro wrote:

Phillip> Actually, this is one of those rare cases where optimization
Phillip> and clarity go hand in hand. Human brains just don't handle
Phillip> nesting that well. It's easy to visualize two levels of nested
Phillip> structure, but three is a stretch unless you can abstract at
Phillip> least one of the layers.


Also, if you think about nesting in a class/instance context, something like

    self.attr.foo.xyz()

says you are noodling around in the implementation details of self.attr (you
know it has a data attribute called "foo"). This provides for some very
tight coupling between the implementation of whatever self.attr is and your
code. If there is a reason for you to get at whatever xyz() returns, it's
probably best to publish a method as part of the api for self.attr.

Good point: this is also known as "Law of Demeter" and relevant summaries and links are for example at http://www.ccs.neu.edu/home/lieber/LoD.html .



Alex

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to