Architecture for WinForms applications?

后端 未结 7 2014
情书的邮戳
情书的邮戳 2020-12-23 23:07

I have started a WinForms project a few weeks ago and as I did not really know what features I wanted, I just added them along the way. This now caused a horrible mess where

7条回答
  •  醉梦人生
    2020-12-23 23:34

    What I would always go for (first) is to have a layered application

    • Presentation Layer (JUST UI and databinding logic)
    • Interface Layer to the Business Layer (defining the contracts for accessing the BL)
    • Business Layer implementation (the actual logic, data validation etc...)
    • Interface Layer to the Data Access Layer (defining the contracts for accessing the DAL)
    • Data Access Layer implementation

    This organizes your application extremely well. Then I'd look for some MVC kind approach. I did not develop so much with WinForms, more with Asp.net and some Java Desktop clients (where I used MVC). WinForms works more with the .Net databinding approach (DataSource, DataMember,...). You should go for that approach instead of trying to force something other. I found that it doesn't match that well.

    What's always useful is to lay out our UI logic into different controls (like UserControls in Asp.net). This facilitates reuse.

提交回复
热议问题