Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separating Windows Forms and Classes C#

Tags:

c#

winforms

I am looking for a way to design a C# application. I understand 3-tier model, but idk how to apply this in a good C# design.

I have looked some asp.net mvc tutorials, but I am looking for a windows-form based tutorial.

is there any book or website to learn a way to implement this?

like image 430
Nick Avatar asked Dec 14 '10 03:12

Nick


1 Answers

I believe that traditional MVC is overkill for WinForms. The form is the view, and there's seldom a need for a separate controller. The model is just a class (usually implementing INotifyPropertyChanged). You can use data binding to notify the view that the model has changed.

The important point is to minimize code under buttons. If it's form code, it should either (a) be UI-specific or (b) be delegating calls to the model. Any business logic should be in the model or in classes on which the model depends.

Avoid making the model a God Object. It can delegate internally to other classes.

EDIT: You may want to consider moving the bound data out into a separate object owned by the model. I'd call this Presentation Model, but I don't want to put words in Fowler's mouth.

EDIT2: Important - the model must have NO KNOWLEDGE of the view and NO UI code (such as dialogs).

like image 82
TrueWill Avatar answered Sep 30 '22 20:09

TrueWill