views:

43

answers:

1

Hi,

Is it a good programming practice to use the mediator pattern for trivial messages (show an image viewer window etc.) ?

Mediator.NotifyColleagues(Messages.DISPLAY_IMAGE, image);

instead of just using

frmImageViewer.Show(image);

I use the mediator program in my program a lot and was wondering how much is too much.

Regards,
Seb

+1  A: 

It depends.

You should use it when you don't want to create coupling between the component that shows the image frImageViewer and the component that triggers the notification.

If you don't plan to ever add a new window, or your application is simple enough as not to care, you may drop the mediator.

When your application have more screens, and you need to support new ones ( for instance, a preference dialog, and an advanced prefereces dialog ) and you don't want them to know about your controller, a mediator looks appropiate

OscarRyz