Best practices for EventArgs

Topics: CAB & Smart Client Software Factory
Jul 16, 2007 at 9:54 AM
What is the best practices to implement the Event subscription or publishing?

Suppose: There are two methods that I like to publish in View.

1. Foo1(int id, string name) ;
2. Foo2(int arg1, string arg2, string arg3, MyClass arg4 );
3. Foo3(string aa, string bb, string cc, int dd) MyClass ee);

How can I pass the parameter to those events? AFAIK, we have to create either custom object or custom eventargs for that. If I do that way, I need to create the custom class for each and every function since those functions have the different parameters.. Some told me that they use the Collection object or ArrayList to implement.

Could anyone please share with me the way you use in your project?
Jul 16, 2007 at 3:01 PM
When we have to do this (which is very rare) we create custom EventArgs.

That said, when I see an event that has to pass five parameters, I consider it a code smell. It tells me that somewhere a business object is missing data. 99% of the time in our code base all we have to do is use a typed EventArg<T> and pass a business object.