Re: [Twisted-Python] composition VS. inheritance

2020-07-02 Thread Ian Haywood
On 1/07/2020 1:41 am, Barry Scott wrote: On Saturday, 27 June 2020 07:47:14 BST Ian Haywood wrote: I've been told in code review to use composition instead of inheritance, which is fine in a general sense but I have difficulty applying to twisted-specific task thanks for these pointers eve

Re: [Twisted-Python] composition VS. inheritance

2020-06-30 Thread Glyph
> On Jun 30, 2020, at 12:26 PM, meejah 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 serializ

Re: [Twisted-Python] composition VS. inheritance

2020-06-30 Thread meejah
As others have pointed out, you're stuck with a certain amount of inheritance to use Twisted. However, this can be fairly minimal. For new code trying to follow a "sans-io" approach is good too. The go-to example of this for Twisted is Hyper/H2 and its integration into Twisted Web for HTTP2 suppor

Re: [Twisted-Python] composition VS. inheritance

2020-06-30 Thread Barry Scott
On Saturday, 27 June 2020 07:47:14 BST Ian Haywood wrote: > In smb I have a SMBPacketReceiver that inherits from t.i.p.Protocol, it > breaks the incoming TCP stream into logical packets (the analogue of > LineReceiver in line-based protocols). > > I then subclass SMBPacketReceiver to SMBProtocol

Re: [Twisted-Python] composition VS. inheritance

2020-06-27 Thread Colin Dunklau
On Sat, Jun 27, 2020 at 8:48 AM Ian Haywood wrote: > In smb I have a SMBPacketReceiver that inherits from t.i.p.Protocol, it > breaks the incoming TCP stream into logical packets (the analogue of > LineReceiver in line-based protocols). > > I then subclass SMBPacketReceiver to SMBProtocol which d

[Twisted-Python] composition VS. inheritance

2020-06-26 Thread Ian Haywood
In smb I have a SMBPacketReceiver that inherits from t.i.p.Protocol, it breaks the incoming TCP stream into logical packets (the analogue of LineReceiver in line-based protocols). I then subclass SMBPacketReceiver to SMBProtocol which does a lot of the "heavy lifting" analyzing incoming packet