Delphi ListView Fast Operation General implementation of the implementation of the article

Source: Internet
Author: User

As we all know, Delphi ListView class Direct Add, Update, delete operation speed is relatively slow, especially when the amount of data, such as the amount of data reached 5000, 10000, 50000, speed is really can be said to be "surprisingly slow." In fact, the rapid operation of the method is very simple, as we all know. In my work, many projects are used to ListView, and the response to speed is higher, so there has been a rapid operation ListView code scattered in a number of projects in many modules of the problem, and, when the interface layer data display requirements change, the natural occurrence of "repetitive code common problems." Considering compatibility issues with previous versions, there has been no mature component referencing third parties. In view of the fact that "repetitive code in a program is the easiest to cause problems and must be eliminated", you have designed a more general class structure for solving such problems. Of course, it's far from a "generic framework" (a lot of people on the market now like to make what they do, whatever it is, as a framework). In the project of adopting this structure, it is easy to implement the MVC pattern to achieve the low-level and basic requirements of the separation between business logic and interface display.

Summary:

The advantages of using this kind of structure to realize ListView fast data operation:

1, can quickly realize the MVC pattern, to achieve interface display and business logic separation. In the Controllor class, the instantiated data displays subclasses, and the corresponding methods are invoked to realize the increase, deletion and modification of the display data.

2, compared to the original fast method, encapsulating the list of memory data greatly simplifies the operation of the list object (especially when there are many identical or similar data requirements in the ListView of different form), and reduces the likelihood of errors in the list creation, data manipulation, and release operations.

3, simplified a number of the same, similar data display control code, for each of the data to display and ListView, only need to instantiate a display subclass, to avoid direct application of the original fast method, control code dispersed in each specific form class problem.

4, the display of data business information is centralized, when the request to display information changes, only in the data display subclass of this class changes can be.

This generic class structure still has some deficiencies, welcome friends who are interested to continue to improve:

1. The external invocation method of each application layer class is very similar (please refer to the developed sample source code), indicating that some common methods do not perform better abstraction.

2. Fast access to the base class does not abstract the behavior of its subclasses, causing the application-layer calling code of the subclass to be very similar. The purpose of this design was to keep the class structure fully extensible. In fact, the base class can be improved by replacing the abstract virtual method with the interface so that the base class implements a better encapsulation and better satisfies the design principle of "dependence on stability" and "programming for Interfaces". This allows the application tier to instantiate a class of its own business needs to implement this interface. But the Delphi interface does not resemble the real interface, usually inherits from the Tinterfacedobject class and so on, greatly limits the class structure level evolution. (because in a language environment that does not support multiple inheritance, it is not easy to add a higher level of abstraction).

3. The current version does not provide the ability to sort data for a column.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.