Public Event Handlers

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.
 
L

Lloyd Dupont

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top