Jason Hildebrand wrote:
I eventually realized that using classes would clean a lot of this up. With classes you only need one method per event. Any subclass which overrides this method can call the superclass' method (or not) when it needs to, thereby controlling whether the new functionality is executed before, instead of, or after the event. </storytime>
Well, since we're talking about events, maybe it should done as events. The problem I see with classes is that they aren't composable -- you can make one, and only one subclass (at least, only one subclass will be used). Mix-ins are composable, since you can apply the mix-in to an already-mixed-in class (well, at least with your patch), but they are a little difficult to work with, and tend to be tightly coupled to the code they are modifying.
Events don't really solve those problems, but at least they make it a bit more explicit. You still have to deal with the order in which registered actions are executed, what effect those actions can have on the flow of the code (e.g., can they stop the event, or modify the event), and you may want both pre- and post-events for nearly any event. And you have to specify all the events, and any data associated with the event.
Hmm. Seems like Jason and you talks about something like CLOS multimethods and it's call-next-method. Although this is a powerful concept, I sure the extensibility of the WebKit could be achieved more easily, without having to introduce overly broad concepts.
The extensibility would depend upon good framework design, not the hacks like mixins that patche living objects on the fly.
Anyway, we could address these problems one at a time.
Take for example my struggle with custom Session class. Why I can't tell the WebKit (in contextInitialize, for example) to use specified class instead of the standard Session? It would solve the problem neatly without the need for mixins. And I'm free to either subclass the Session class or use brand new class for this purpose.
But I think events are a good metaphor, even if it's still work. I believe there's some good generic frameworks on PyPI for event dispatching. At least, I remember seeing one somewhere that looked good, in the last month or two.
http://pydispatcher.sourceforge.net, I bet. Quite impressive.
------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss