views:

37

answers:

1

I am working on a rather large WinForms application that has dozens of controls and hundreds of functions. Right now MS makes every new event handler in the main form's .h file, and this file is growing out of control. It currently numbers in the thousands of lines, and is still growing.

What is the best way to split up the code in a big WinForm application like this? Is it even possible to put event handers in separate files, and if so is this bad practice?

A: 

For the moment my only idea to overcome your problem is to modularize the business logic into separate classes. Even if you do not really have business logic you could start creating a sort of UI class library, i.e. having some classes whose methods do the same thing that you do in your event handlers now.

Maybe this even leads into a better understanding of your application. Sometimes, having that much event handlers clearly indicates that your class (and most often even your form) does too much, or at least too much implicitly. But that is rather generally speaking since I don't know any line of your code.

Maybe you could show us some code or further describe what your application does.

Eventually, modularization could be a solution to your problem.

Andreas