[Twisted-Python] RPC design questions
glyph at twistedmatrix.com
Tue Aug 23 14:30:29 EDT 2011
On Aug 23, 2011, at 10:37 AM, Tobias Oberstein wrote:
> class AutobahnDeferred(Deferred):
> def call(self, *args):
> return self.addCallback(self.protocol.rcall, *args)
> Pro: most terse
> Con: only supports single callback no errback
Con: subclassing in general is a bad idea. Subclassing Deferred is an even worse idea. What if Deferred one day gets a new method called 'call' that does something different? Your code would all break.
> Anything why I shouldn't do?
Providing three different ways to do the same thing just so that you can use different syntax depending on your mood is a recipe for making your code hard to read. Pick one style, stick to it as much as possible - consistency is more important than the benefits of any one particular style :).
(Except the subclassing one. Don't do that.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python