views:

91

answers:

3

I can't decide if it is good or bad to make many user controls. I am only doing it cause I find it easier to work on a control where there are not a lot of components. If something needs to be fixed it is also easier. Kind of like how you split your program up in a lot of classes.

However multiple controls adds a bit more complexity when it comes to passing data around. I guess my question is more if it is normal to create a 'god' class when it comes to GUI programming in winforms.

Almost every video tutorials I see, they only work on one form! While I can use like 5 controls before I have a form.

+5  A: 

Have you heard about encapsulation and components? It is just your case.

Developer Art
Ye I have. Just curious if it was different when it comes to GUI programming in C#, since I got the impression I was the only one doing it.
bobjink
The common sense applies to GUI as well. Just keep balance between convenience of componentization and inconvenience of passing messages among too many of them.
Developer Art
A: 

Well from a Web Developers perspective -- no, I don't believe so. In fact I believe in the NerdDinner book for ASP.NET MVC there's a section where the author(s) creates a partial (similar to usercontrol) for the sake of readability purposes. And these are the top guys at MS who wrote this book.

Beavis
+5  A: 

Reasons to create User Controls in WinForms:

  1. Reuse of functionality.
  2. Encapsulation and data hiding.
  3. Readability and maintainability.
  4. Single responsibility principle.
  5. Design-time editor integration for assignable properties.
  6. Ability to refactor/enhance/reuse in the future.
LBushkin
+1 for points 2, 3, and 4.
gWiz