Search code examples
c#user-interfacebusiness-logiccode-separation

Separating UI and logic in C#


Does anyone have any advice on keeping logic out of my GUI classes? I try to use good class design and keep as much separated as possible, but my Form classes usually ends up with more non-UI stuff mixed in than I'd like, and it tends to make maintenance a real pain.

(Visual Studio 2008 Professional, C#, Windows apps).

Many thanks.


Solution

  • Put your logic in a separate assembly; and, build that assembly without its referencing any GUI packages (e.g. System.Drawing, System.Windows.Forms, etc.).