In the process of participating in the interview, I asked the Delphi programmer for the application: "Pascal is the third generation of process-oriented programming language, but it turns into objects from the 1980s, you are currently in Delphi. What kind of views do you believe in object-oriented support? "I believe a lot of senior Delphi designers read the Delphi source code written by Borland. These source code is the good friend of these designers. I also read a lot of programmers with Delphi. Writing code. The code they wrote and the teacher taught me when the teacher of the Basic course gave an example code, a large pile of global variables, a lot of common functions. I calculate the number of times of calling these functions, 80% function Only calls only, that is, these so-called universal functions are not as universal when designing the author. This programming thinking is still a process-oriented programming in the 1970s. Perhaps this is also a reason for the framework of Delphi. Each time you create a form, you will automatically create a global variable of a form class (i.e., entity object) in unit files. This is actually a very bad implementation, although it is very simple and practical. : You don't need to program a program with a form, which is set to a main form. This instance is created in the Program file. The concept of object-oriented programming should have more detailed explanations in the professional programming course. If you want to feel object-oriented programming in an unconsciousness? It is recommended to use SmallTalk or Java. These two languages are completely used for object-oriented thinking. There are many masters talk about object-oriented objects in Delphi. Technology to enhance development efficiency. I want to talk about the feelings of using Delphi to write code using Delphi programming: 1. I don't like to define a lot of variables: replaced by I define a class, put The associated variable is defined as the private variable of the class, and then move the process or function of these variables to the class, it will change it into a class. I found that I have a lot of benefits, I no longer need to define one The big pile of variables, I just need to declare an object variable. I don't need to take care of the relationship before working. These relationships are implemented in the class; if there is similar implementation in other places, I will It doesn't have to copy code as before. The copy code was used as a magic weapon by my colleague, but his program is too difficult to maintain, so that he will always say to rewrite these code. Of course, you can still These code encapsulates into a general function. After a while you may find that you have defined hundreds of universal functions in a public unit, do you remember them? How do they use it? Hey, to come from Cheng Bai In the thousand functions, I find the functions you want to do, and I have to make sure that they want the function. It is better to write a calculation. So there is a general function. So I have the following emotions: 2. I Almost do not write universal functions Instead, I put this function into the specific class. If you write some of the versatile functions, such as the API declaration function, it seems that there is no way to solve such problems. But I still I don't like it, I only declare the API function in the common unit, then introduce the API function into the class, so I don't have to look at Microsoft's words or understand the documentation. 3. Reconstruction How is it in delphi? If you follow the two principles above, after a while, you will find, 噫, how is this class so big? (MM like big ...) Take him Some. Let's take a look at
The use of object-oriented programming technology, carefully asked these source code, and slowly you will understand the benefits of object-oriented programming, if you can go further, you can also give a back to the three, and associate it. Whether it is two or three layers, or multiple layers. Whether it is a current intermediate programming, service-oriented, component programming, in fact, based on object-oriented programming. Object-oriented programming is the most basic idea, just like people's walking. I can't imagine how people who walked will run, go to jump? I don't know if you can think of it? In fact, my title is too big, I just want to talk about my feelings for Delphi object-oriented programming. For Delphi and VCL Framework, I can only be counted as a door.