[Twisted-Python] composition VS. inheritance

Glyph glyph at twistedmatrix.com
Wed Jul 1 00:26:58 MDT 2020


> On Jun 30, 2020, at 12:26 PM, meejah <meejah at meejah.ca> wrote:
> 
> I recently wrote a relatively simple protocol to try this "sans-io" style
> and was happy to start with the state-machine (using Automat). This
> forced some good decisions. Then I worked outwards to the "more boring"
> bits (framing and serialization/parsing).
> 
> (Hmm, this should almost just be a blog-post maybe ;)

One thing I should mention is that while there aren't necessarily great examples of stacking protocols like this at the parsing layer, some parts of Twisted do work by delegation and composition.  For example, in twisted web, Resource objects are thoroughly disconnected from the protocol layer, rather than, say, the various 'irc_' methods exposed in the IRC server.

So another way to look at this is to extend things like the Resource pattern down into the parser, rather than trying to think of a way to take apart the Protocol object in a wholly novel way.

-g

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20200630/0beff659/attachment.htm>


More information about the Twisted-Python mailing list