On Apr 15, 2009, at 5:25 PM, kirby urner wrote:
I'm thinking of Adam's comment that he never decorated a class and
didn't regret it, and, truth be told, I've not experimented with that
feature much.

So I wanted to give a use case, see if PPUGers think it flies.

At the Side Door after the meeting, John Melesky reminded me that decorators are often used in places where metaclasses are used, and ORMs are a case where metaclasses can be used well; a class you defined is instrumented as a bridge to a DB subsystem.

Here's an excellent talk on class decorators, also talked to this guy
(Jack Diederick) at the CPP / Iceland party (lots of Twisted guys):

http://pycon.blip.tv/file/1957258/

This was the talk that I saw that prompted my outburst. Jack identified four ways decorators are used: registration, verification, augmentation, and fixups. This vector example would be a case of augmentation.

Registration was the only case I could think of that worked well in my mind. In the past I've got the augmentation route and felt that it made the code less readable and less understandable; I should have composed a helper object. In this example that method or a straight subclass (or even mixin) would be easier to read in my opinion.

But for pure library code like an ORM, where the user is not intended to need to dive into the guts, they can be useful.

Perhaps we can find some code in the wild that make good use of them?

Adam
_______________________________________________
Portland mailing list
[email protected]
http://mail.python.org/mailman/listinfo/portland

Reply via email to