Powerful Delphi rtti– and the need to understand a variety of development languages

Source: Internet
Author: User
Tags soap

January 27th, 2005 by Raptor

Wind Yan in the "18-like martial arts"? The problem of being entangled in multiple languages. I said in my reply:
Many languages as long as you can understand a bit of it, there is no need to master each one
But if only a few one or two languages are not.

Because read some of the application of the reflection technology of Java, suddenly think of Delphi Rtti is also very strong, so try to take the data set, with Rtti to achieve its object. It used two of
The night time will be done (not because the beginning of the wrong object-the base class with the TObject, in fact, it should be used tpersistent), it is very simple.

Suppose you have a Adodataset control that connects to the Northwind database, and SQL is:

SELECT * FROM Employee

Now to put it in the contents of EmployeeID, FirstName, LastName Three fields are displayed in the ListView. I implemented a DataSet proxy class through Rtti, which made the code much easier (two days trying to get the results sorted out separately). The results are broadly as follows:

Typetpdsemployee = Class (Tmproxydataset) publishedproperty employeeid:integer Index 0 Read getinteger Write SetInteger; Property firstname:string Index 1 Read GetString Write SetString; Property lastname:string Index 2 Read GetString Write SetString; End;...emp: = Tpdsemployee.create (ADODATASET1); While Emp. ForEach dowith listview1.add dobegincaption: = IntToStr (emp. EmployeeID); SubItems.Add (EMP. FirstName); SubItems.Add (EMP. LastName); End;emp. Free;

The benefits are obvious compared to the traditional implementation code.

But when I realized this tmproxydataset class, I could not help feeling bitterly, which I should have thought of three years ago.

When DELPHI6 was launched three years ago, I discovered that its soap function was accomplished by Delphi's powerful Rtti, why did I not think of going into the Rtti of Delphi?

This time it is not because I saw some Java material, I may not think, so it is very important to know more about other languages. Especially recently, dynamic language has been paid more attention, although they can not be compared with native development in performance, but it has important enlightening significance in many development thoughts.

After doing this, I realized that Delphi is actually the most dynamic of all native development languages, not much less than virtual machine-based Java and C #. Just for a long time in the development of RAD, did not realize it. The programmer was spoiled under RAD.

After this, I'm going to try again. Rtti implements XML persistence for objects (basically copying the SOAP implementation Code of Delphi itself-_-| | | )。 This idea should be much more convenient than the XML Data binding I used originally, at least not to write the troublesome XML schema.

BTW: Previously did not pay much attention to rtti, efficiency is probably one of the most important reasons, but now it seems that compared with the virtual machine language and even dynamic language, Delphi as a native application development, this rtti efficiency loss is actually not as large as the impact of imagination. In exchange for the development efficiency of the big increase is still worthwhile.

BTW: Copy the fox's section of CSS (<pre>). ^O^

http://blog.csdn.net/diligentcatrich/article/details/5500748

Powerful Delphi rtti– and the need to understand a variety of development languages

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.