Public Event Handlers

  • Thread starter Thread starter Leslie Sanford
  • Start date Start date
L

Leslie Sanford

Is it considered bad style to make event handlers public? Something like
this:

public void Send(object sender, SomeEventArgs e)
{
// Do stuff...
}

The idea is that by making the handlers public, a third party can
configure the flow of events through an application by attaching and
detaching objects with events to objects with event handlers. The
objects involved don't have to know about each other.

I can't find anything in the guidelines that say one way or the other.
 
I think that, wether or not the method is an event handler, the question is:
is it appropriate to make this method public?

difficult question...

my politic is the following:
I made as much as possible method public and virtual.
If calling a method require additional work to maintain the object in an
appropriate state (i.e. other method call are required not to break the
object) I make it protected or internal.
If the method just make no sense to the outside world (such as a utility
method) I make it private.
 
Back
Top