tags:

views:

62

answers:

2

If I create a Abstract BaseForm for my Windows application, I can use it to do common things when the application's forms are loaded. I can also override the OnLoad method, or I subscribe to the Load event (BaseForm_Load).

Which approach is better from the design and performance point of view?

+1  A: 

Unless I need to modify OnLoad() behavior, I would prefer using subscription to the Load event. It is slower, but I consider it is conceptually more correct.

Also see similar question

ironic
+5  A: 

In general, if you're implementing a base class (ie: subclassing Form), it's better to override the base class methods.

This is better for multiple reasons - these methods typically happen first, and always have guaranteed order (if you use the event, other methods can be run via other subscribers that could interfere with your method). In addition, there is (slightly) less overhead to doing this.

Probably the best reason, though, is that this is the accepted practice, which makes your code more maintainable, especially by other developers.

Reed Copsey