Christopher Smith on 28 Jul 2003 23:24:11 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [ALACPP] Thoughts on last night's code sample |
On Mon, 2003-07-28 at 13:17, Jon Stewart wrote: > > Criticism 3: Use event objects, rather than argument lists. > True, but. Sometimes arguments can be lumped together into an actual > object (one that has some behavior) and sometimes they can only be lumped > together into a struct. And, damn, creating dummy structs is annoying, > with or without boost::tuple. In our networking framework, each "type" of > connection got a separate class; within those classes, the number of > available messages to send and receive was quite small, and argument > duplicates were quite rare. Not having to define a separate class for each > message was a definite win -- the very best part of our network library > was the minimum of busy work necessary to create a new network message. > Because of that leverage, we were able to get an incredible amount of work > done in short order. I don't know. Usually when I create events, I end up wanting to have behavior on them, or at least a discrete type. Things like serialization, etc. It just works better when they are discrete types, because even if I have a generic serializer I need to somehow disambiguate between different kinds of events. You can use things like inheritence to do some clever event dispatching. You also have the benefit of actually knowing what all the events are in the system (nice use for typelist) in a really unambiguous way. The biggest reason though is it is just sooo much simpler (particularly when you are debugging), and I try to place some kind of a premium on XP's notions of KISS. If you hate making event objects though, Boost PP sure makes it a lot easier to do argument-based events than any other solution (if anyone mentions varargs I'll kill them), so I'll concede that this really a question of design goals as opposed to the quality/correctness of the design. -- Christopher Smith <x@xxxxxxxx> _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp