On Jan 31, 2005, at 11:38 AM, Bryan Pietrzak wrote:
On Jan 31, 2005, at 1:16 PM, Mike Lazear wrote:
I guess if we wanted to make a handler really robust we
could check to make sure the event class and kind are correct as well
as the
signature & ID and the Command. That's a bit of an overkill if we
have a
single event attached to a single control but would be necessary if
we have
multiple event class & kinds attached to a window that has multiple
controls.
I code defensively, and in this case all my event handlers check for
class and kind, and signature and ID where appropriate. (And I use
asserts when things don't match, like in the default of switch on
event kind for example -- makes it easy to find errors that way).
It's just very easy to get into the habit of doing that. Then, later,
changes to your app can't as easily create unintended side effects if
your original code was defensive and you use asserts in that code to
let you know when assumptions fail.
That's probably a smart way to do it. The extra code is minimal and
it makes it easier to copy event handler code from one place to
another. At run time I believe there is probably no noticeable
difference in speed. The asserts in the default switch is also a good
idea to guarantee there are not events happening that you are getting
but not dealing with.
I've only finished about 10 of my 100+ dialogs so I think I'll go back
and adjust the code based upon both Larry and your suggestions.
Thanks,
Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden