Difficulties and Solutions in the Development of Winform Interface

DevExpress Winforms Controls has  built-in more than 140 UI controls and libraries, perfect to build smooth, beautiful and easy-to-use applications. DevExpress WinForm v20.1 is newly released, want to experience it? Click to download>>

When we develop various applications, we will encounter many different problems. These problems involve architecture, module combination, interface processing, common part abstraction, etc. Here we take Winform development as an example, choosing from system modularity and interface components , Business module scene division, interface base class and auxiliary class processing, code generation tool auxiliary development, etc. Introduce the difficulties encountered in the actual project development process and related solutions, so as to analyze how to gradually improve efficiency and overall user experience of.

1. System modularization

Software and construction engineering are very similar, both need to build a large and fully functional system, and engineering also means that multiple people are required to collaborate, so a large system needs to be divided horizontally or vertically into each that can be completed independently. Modules, although there are connections or interactions between various modules, they can basically be constructed in a modular manner. This is also the essence of engineering development.

Take a software management system as an example. We try our best to focus on the customer’s business needs. For some common content such as access control, dictionary management, etc., because their processing logic is basically more in specific areas It can be fixed and can be used independently and repeatedly as much as possible. Sometimes, for a specific business, many processing rules are also unchanged at the same time, so it can also be divided in the way of business modules, similar to the way of general modules reuse.

Modularity is similar to the way children build building blocks to build a desired shape. Although software and buildings are definitely more complicated in this respect, modular systems are the general trend and are also important measures to simplify development, ease maintenance, and improve system robustness.

WinForm interface development tutorial

Two, interface component selection

In the built-in traditional style of Winform, although many good interface components are provided, the overall effect is still relatively old-fashioned. In order to enhance the processing effect of the interface, we generally use some third-party interface kits as the basis of Winform development. In addition to improving the overall interface effect, it also provides rich processing and response at many control levels.

WinForm interface development tutorial

I have tried various types of interface kits before, but I still have a soft spot for DevExpress, not only because it is an interface kit developed by a large software company, but also because it provides a lot of rich interface components and powerful attributes at the interface level Settings can greatly meet the complex requirements of various interfaces.

Using the DevExpress interface kit can make the interface we develop more beautiful and the user experience better.

WinForm interface development tutorial

Or similar effect

WinForm interface development tutorial

Third, the scene division of business modules

As mentioned earlier, a system can be divided into independent modules for development or reuse in a functional manner in order to simplify development, easy maintenance, and improve system robustness. For business modules, we can also subdivide it further. In the general system interface, most standard methods are to display the query list of business data, and then edit, view, and delete specific records as needed. We put the regular list interface, add, edit, view, import and other interfaces together. Except for the list page, other content is processed in the way of pop-up dialog boxes, as shown in the following interface diagram.

WinForm interface development tutorial

For the display of list content, the general display effect is as follows, mainly showing the two-dimensional table information in the database.

WinForm interface development tutorial

In addition to the list interface, the other is the detailed display interface of the data. The content of this interface can be more diversified, such as carrying various controls, such as text, date, picture, drop-down list, tree list, and our custom Some controls, such as display controls for attachments through management.

WinForm interface development tutorial

With the display effects of these standards, we can refer to these and use code generation tools to assist the generation of page content. The generation rules can be based on database metadata.

Fourth, the interface base class and auxiliary class processing

We use the regular business module interface to analyze, mainly the detailed view or editing interface, and the list interface. For the convenience of these interfaces, we can abstract part of the interface processing logic or share part of the content, and put it in the interface base class BaseEdit or BaseDock and other base classes Inside, as shown in the following interface.

WinForm interface development tutorial

As far as possible, some general rules related to business data processing are placed in the base class, and the changed part can be processed in the subclass. This can simplify the code of the generated interface, improve the reusability rate, and reduce the difficulty of maintenance and the bloated code. For general business systems, it may involve the use of different databases, such as SQLServer, Oracle, Mysql, PostgreSQL and other databases. Then this part can be processed by using Microsoft Enterprise Library or other ORM methods to realize the system's use of multiple databases Good support.

WinForm interface development tutorial

Five, code generation tool assisted development

Through the above introduction, the general part is used independently as a module. The interface of the business module is mainly divided into two parts: the list and the editing and viewing interface, and each has performed a certain base class abstraction, so it has been relatively simplified, but for business In terms of data, we still need to do a lot of repetitive tasks, such as interface display, interface assignment, and call interface processing. If these are fixed to business objects, the rules are actually similar. Then we combine code generation tools for batch Just generate it, and some fine-tuning after generation can greatly reduce the probability of errors and reduce the amount of code written.

When we develop software, the solution project is based on a certain hierarchical organization. In each project layer, the relationship of each class is also determined. With the help of auxiliary tools (combined with template engine), we can quickly generate the code we need, and Greatly improve the efficiency of our software development, the Database2Sharp code generation tool is a development tool specifically for our own framework structure.

The Database2Sharp code generation tool is mainly based on the metadata information extracted from the database, and generates the hierarchical class code required by our framework according to the table information and relationships, field information and other content.

For Winform development, you can generate standard interface codes based on the window interface classes of the Winform framework or hybrid framework. The list interface has pagination query, import and export, advanced query, edit, and delete event bindings by default, and the edit interface has access to data and Displayed in the control, perform update or write operations after saving.

WinForm interface development tutorial

WinForm interface development tutorial

WinForm interface development tutorial

Six, other

In addition to the parts introduced above, in general, we can also make some independent component modules in a business way to facilitate repeated use. This is a major aspect. Modularization generally requires a corresponding framework structure to be constructed. Each independent module is handled in accordance with a unified framework structure, which can greatly improve the efficiency of code development and reduce the difficulty of maintenance. The Winform development framework is shown below.

WinForm interface development tutorial

For mixed Winform development, the deployment of Web API modules and the encapsulation of Web API calls by the client are also designed, as shown below.

WinForm interface development tutorial

This article is reproduced from the blog garden-Wu Huacong


DevExpress Technical Exchange Group 2: 775869749 Welcome to join the group discussion

To get first-hand DevExpress control information, please visit DevExpress Chinese website!

Huidu high-end UI interface development

Guess you like

Origin blog.csdn.net/AABBbaby/article/details/108072996