Why *should* we use EventHandler

后端 未结 6 803
无人及你
无人及你 2021-02-01 14:26

I hate EventHandler. I hate that I have to cast the sender if I want to do anything with it. I hate that I have to make a new class inheriting from EventArgs<

6条回答
  •  -上瘾入骨i
    2021-02-01 15:00

    I agree with you, the convention is stupid and/or antiquated. Do it the right way, with proper type safety and generics.

    It comes up all the time that you have a task to do, and you can follow the way the last guy did it OR do it another way that you think is probably better.

    The first choice is usually chosen -- do it the same as the last guy, and you won't get in trouble. But the second choice is what improves software over the long haul. (Or at least it CAN improve it, if you're right that your way is better! :) )

提交回复
热议问题