A C ++ programmer's Delphi learning notes

zhaozj2021-02-16  53

A C programmer's Delphi learning notes said that he stood in a C programmer's position, and there was such a new man who used Delphi. Just a few weeks ago, I also wrote the dignity of C . Various reasons, today I have to learn Delphi, familiar with Delphi, and I will not be impatient with life.

I gave my fifteen days, I don't know if I can't you master a language? I chose Marco Cantu's "Delphi from the entrance to" and "Delphi Advanced Development Guide" as a learning book. The first book is called "from introduction to proficiency", but if you are not familiar with an OOP language, then this book is not suitable for you. For me, it is right. The total thickness of the second book has a total of 1,500 pages. Well, one hundred and one hundred pages will be almost, I hope I can do it.

I decided to record my thinking and confusion, as I entered the new field of remember, I hope to provide a little help for the same way. An environment "Want to do something, you must first sharpen your equipment", it is very important to familiarize the development environment. Different from the MDI interface of the VC, Delphi uses multiple independent form design. Does this indicate that Borland has advocated the interaction between components? I secretly guess.

1.Desktop settings can be separated from Project, and Desktop settings are prioruously for Project settings.

The 2.to-do list is a good tool for reminding yourself or others.

3.appbrowser feels very similar to the main interface of the VC. It also provides functions such as symbolic prompts, Code Completiont. Well, there is also a Class Completion in VC, which can be automatically completed between the declaration and the realization.

4. The concept of project group, a bit like the .NET platform, but .NET is multi-language collaboration.

The core of two language delphi is a VCL library. Its basis is Object Pascal. "From the introduction to the proficiency", "Object" is said to use the two chapters, but only the word does not mention "pascal". Well, it's okay, I remember.

1.Use is used to reference external units. Unlike the header file, USE has no transfer.

2. Delphi uses the reference object model, the object variable only holds an object reference, no longer hold the object itself, and all objects are manually assigned.

3. Delphi's package is very strange, the setting of the class member access is only role outside the unit. Within the unit, you can access the class private member from the outside of the object. Friends explain that it is equivalent to C friends, and it is important to be big. Is the friendship be two-way? (Use the Unit method as a friend, A can access B, B be able to access a) Friendship has the transfer property? (Use the Unit to use as a friend, A can access B, B can access C, and A must access C). In my opinion, this concept of friends is incompatible. I hope that one day I can understand the consideration of Delphi.

4. After the declaration of the object variable, the actual generation of the Delphi object needs to be called the constructor. The constructor is a special type of method, which is inherited from TOBJECT and overloaded. Do not use the keyword and use the class method to construct the object, I think this is a unique usage of single inheritance.

5. There is a dynamically created TButton example in the book. Use CREAT to create an object, but it is useless to explicitly release.

. I suspect that memory leaks will happen, and I think about it, it is responsible for the release of TButton's container TForm, and my friend confirmed my thoughts. Delphi avoids the trouble of manually release memory.

6.Delphi's keyword is annoying, long and more, there are more places to type. The benefit is to provide more information for the compiler to find the error and speed compilation. 7. Due to the reference object model, there is no longer a direct object access in C , only a problem that the pointer and the polymorphic mechanism are only active.

8. Use Message to point out the method you can handle, hey, let me think of OWL, Borland's similar extension of C language is really nostalgia.

9. A large number of dynamic type conversions, which is the characteristics of Pascal?

10. Form inheritance, as if the properties of the control can be inherited.

11. Very strange design. There is a class of methods, but the class variable is not required to simulate the variables of the UNIT.

12. If my guess is good, the Events of the control should be "object method pointer".

13. Extremely powerful mechanism: class reference, which can be dynamically established in the same form. Similar to C , I am afraid to use Builder mode.

14. Parameter objects are passed by reference, assign values ​​by reference, only partial classes provide ASSIGN methods to copy objects. Hey, the value of C , I miss.

15.FinalLyl! Solved the problem of resource release in C to high tips. But why can't you use ExcePt? do not understand.

16. Attributes and events? ? It's really customized for VCL. In fact, attributes and events are not an object-oriented necessary elements.

17. I think the entrustment model of VCL event processing is similar to Java. Just Java's Listener can handle more

The existence of Listener, Delphi's event attribute seems to be able to handle one? However, it is much more than the processing speed.

18.a) Routine Register, D) installed from Tcomponent class inheritance, B) new construction programs, c). The convenience created by the VCL component is really touched.

19. The book says that VCL is better than ActiveX, because ActiveX has no complete inheritance mechanism, I dare not agree. Aggregation is the mechanism that is first inherited.

20. Butterface, ugly! ! I even doubt whether this is the design of Hejlsberg. It is completely like a temporary patchwork language component for COM, which is uncoordinated with an overall household. The interface itself is powerful, but the bad design will make it use into a pain. In addition to COM and multiple inherits, I think no one is willing to use it.

All, Object Pascal gave me a deep image. Next, I will learn VCL, and how Borland is how to make the ingredients of such languages, assemble the weapons developed. Three VCL

"From entry to proficiency", the author's arrangement is really bold. Don't talk about how to put the control on the Form, poured from the VCL. I admire the author's discouragement, straight into the core of the problem, embarrassing the muscles to meat, first place the context to you. You know, this has the risk of losing many readers.

1.TOBJECT, the source of thousands of classes. The RTTI information is placed here, this is the convenience of the single single inheritance.

2. A detail: tbutton.instancesize = 504! It's really wasteful. Algorithm analysis is often used in space for time, which should be used in a spatial replacement.

3. As the subclass of TPERSITENT, Tcomponet has fluidization. IDE uses it to write attributes into the DFM file.

4.TPERSISITENT Entrust TFiler and TStream two auxiliary classes to specifically achieve fluidization. Specific implementations include all owned properties of all ownerships from the RTTI, so that fluidization is transparent to programmers.

5. Non-window control? It is believed to be a compensation for low efficiency. 6.components contains all controls on the form, even if their PARENT is another component container, its Owner is also form.

7.Owner and Parent, two confusing concepts. My understanding: Owner is the holder of the object, and Parent is the prendector of the object.

8. Form elements are not packaged! While the convenience of access, it also leaves a chaotic hidden danger, especially in large engineering.

9. The position of the control position corresponds to the Parent's client area, which enhances my confidence: Parent is the rendering of the object.

10. Frames, strong competitors in the form inheritance. The essence is replaced by polymerization. Yesterday, there was a friend: "I think the polymerization can not replace inheritance." Indeed, polymerization is impossible to replace inheritance, but under the conditions applicable to both, the coupling should be relatively loose, and the package is more completely aggregated. Specific to Frames and form inheritance, I feel Frames when I don't involve polymorphism.

11. Delphi's container class, compared to C STL, from elasticity to efficiency, it is far away, and it is easy to have type security issues. Also, Delphi's RTTI mechanism is strong, it can be slightly difficult. This is a side effect without a template mechanism: the entire generic thinking is not used.

In fact, the authors are very good for beginners: do not deeply depth VCL. Although it is still unpleasant, I should be a prominent. Four: Standard components In fact, many Delphi users are supported in many VCL components. Some friends said to me, "In fact, the attributes and incidents are not object-oriented" means that they don't dare to share, I believe he is confused with object-oriented components. In my memory, component is an extension of the object, which is still object-oriented, but has added numerous auxiliary features, including attributes (not C "properties") and events.

1.Form's Components, GroupBox's Controls, Listbox Items, Delphi really likes to use array containers to express organizational structures.

2. There is also a Sleected array, an ITEMENABLED array, oh, the value is also stored by the corresponding item of the Items array.

3.DRAG-DROP. See the title of the book, I don't help but think of IdataObject, Idropsource, IdropTarget several interfaces. In fact, Delphi's drag and drop is much simpler. As far as my understanding, the essence is a DROP notification, unlike COM, packing the data itself. This is why you don't need to support cross-process Drag-Drop.

4. The menu is no longer as a resource, presented to the application programmer, is the Items after the packaged TMENUITEM and organization into nested forms. Two advantages: a) pure one, no longer have a menu resource, the programmer needs to be understood. 2) In the packaging layer, the display menu function is extremely convenient, and the programmer is transparent. To this end, ImageList also packages.

5.Action, which is a two-way event forwarding: each customer control -> action-> onexecute, onupdata-> action attribute change -> Customer controls.

6.OWNER-DRAW, or custom control draws itself? A two difficult choice. From an OO purified perspective, Owner-Draw is really a destruction of the package. Custom controls draw themselves, but they have not worn labor injuries and waste resources.

7.TreeView, tree view. Is XML not good at the expression of the tree? Why don't you give them a combination? Hey, operability, you can think about it, right? It is hoped that the next few chapters can swindle the beginning of work.

------------------------------------ E-mail: Dream_soft@263.nethomepagewww.hisee.netqq: 80512698

This article is DREAMER (DREAM_SOFT) original, copyright belongs to DREAMER (Dream_soft), welcome to all situations. Keep the original text and reserve copyright information when reproduced.

转载请注明原文地址:https://www.9cbs.com/read-22632.html

New Post(0)