[Twisted-Python] General question on components, interfaces, etc.

Terry Jones terry at jon.es
Thu Jun 15 11:24:10 EDT 2006

I've been trying to properly understand components, interfaces, adaptors
etc., as summarized here


and elsewhere.

Although I feel like I understand the various bit & pieces, I still don't
feel like I have a good grip on when these things are most useful, or that
I can recognize patterns where they can be best applied. I do have the
feeling that it's important though.

So here's a specific example and question.

Suppose I am implementing some functionality that I want to be able to
easily replace with an alternate implementation, perhaps written by someone
else. I can use some kind of plugin architecture, and I can specify an
Interface that the plugin code is expected to provide. I can look for
plugins (or have twisted.plugin do it for me), import them, allow a user
config file to specify the preferred plugin to use to provide the
functionality, and I can test the loaded plugin to see that it does provide
the Interface.

All that makes sense, but I'm not sure what it really buys me. An
alternative would just be to document the expected interface (perhaps as an
Interface), and then use __import__() to load the desired implementation.

It seems that without needing adapters, the component architecture doesn't
really buy me anything except a formalism (which I do think has value,
though limited).

Is this thinking more or less correct? How would people go about doing what
I outline above?


More information about the Twisted-Python mailing list