Structuring winforms C # solution

So, I am reorganizing the C # winforms solution to help share and make it cleaner and more organized. The solution tracks small business orders, etc.

I still broke the projects into

App.View - all GUI related code,
App.Data strong> - only data structures and interfaces. No other implementation code
App.BusinessLogic - all business logic code that does not have GUI links

I have some classes that I cannot figure out where they belong. Please let me know your thoughts that each class should design, or if there is another project that needs to be created for this.

  • A class that retrieves user settings from a database
  • A class that retrieves static data from our static data server and returns data result sets.
  • A class that reduces user rights.
  • The model class that stores the hash table of orders
  • A class that sends emails to user action
+6
c # model-view-controller mvp winforms
source share
4 answers

In fact, I think you have something a little from traditional layered architecture. Typically, the models of your data that your application is working on will be stored in the business layer along with code to work with them. Your data layer will use both the data models of your persistence structure and the code to interact with this structure. I think this could be a source of confusion between the proposed locations of your classes and your reaction to it based on your comments.

From this point of view, everything that retrieves or brings will necessarily be in your data layer - this is access to data in persistent storage. What it extracts ultimately translates into business-level objects in which your business logic operates. We are talking about conceptual models, such as an order table, or business activities in a business layer. I agree with @Adron, perhaps with the same confusion about where (3) goes depending on what it really is.

More specific:

  • User preferences are business objects, things that retrieve this data-level object.
  • Static data is converted into a business object (table or view or something else), a thing that accesses an external server is a data-level object.
  • User law is a business object, what extracts it is a data-level object.
  • The order table is a business object
  • Emailing is a business activity, so the thing is that people with people are business objects.

[EDIT] My generalized 3-tier architecture for (simple) web applications

DataAccessLayer

This will include my TableAdapters and strongly typed DataTables and Factoryories, which turn the rows of my DataTables into business objects in pre-LINQ projects. Using LINQ, this will include DataQontext objects and constructors created by LINQ.

Businesslayer

This will include any business logic, including validation and security. In pre-LINQ, these will be my business objects and any other classes that implement the application logic. Using LINQ, these are partial implementations of the classes of my LINQ objects for security and validation, along with any other classes for implementing business logic.

Representation

These are my web forms - basically the user interface of the application. I include some validation logic in forms as optimization, although they are also validated in BL. This will also include any user controls.

Note: This is a logical structure. The project structure usually reflects this, but there are some cases, such as connections to web services, that can be directly included in a web project, although logically the components are indeed in BL / DAL.

Note. I will probably go to MVC through the 3-tier layer when ASP.NET MVC is created. I did some personal projects in Ruby / Rails, and I really like the MVC paradigm for web applications.

+8
source share

You indicated that App.Data should only contain data structures and interfaces, an implementation code that is great if you want to do this, but it leaves you nowhere to put the database access code, other than your application. BusinessLogic assembly.

Perhaps you really need to rename App.Data to App.Model (or something similar) and have a new App.DataAccess assembly that negotiates with the database (possibly using the repository template). Having done this, I would split it like this:

  • App.DataAccess
  • App.DataAccess
  • App.DataAccess
  • App.Model
  • App.BusinessLogic
+2
source share

I would probably go with

  • Data
  • Data
  • Data, although I'm not quite sure what the class does.
  • Data
  • Businesslogic
0
source share
  • → App.Data li>
  • → App.Data li>
  • → App.BusinessLogic or App.Data - not sure what that means.
  • → App.BusinessLogic
  • → App.BusinessLogic
0
source share

All Articles