Why use COM ?????

zhaozj2021-02-11  239

First, why use com

Software Engineering has developed to today, from the beginning of structured programming, to object-oriented, and now come to COM, programming,

There is only one standard, that is, it is desirable that the software can be as tired as the cocific block, which is assembled, not a little bit.

Structured programming is in the form of a function block, by dividing a software into many modules, each module completes different work

Can, try to achieve high-level patching, this is already a good start, we can give different modules to different people

Do it, then in one, this already has the concept of assembly. The core of software engineering is to modular, the ideal situation

It is 100% co-gauge 0%. The development of the entire software is also walking in this direction. Structured programming is just one start.

The next step has an object-oriented programming, which is a huge progress relative to the functional structure. We know

Nature is composed of a variety of different things, and there is a complex thousands of relationships between things, but

The connection between things, interaction, our world is a vitality. We can think that in nature

The secondary thing is a concept that is stable, and the connection between things is varied, sports. Things should be this

The essence of the world. Object-oriented focus is something, this is this stable concept. Everything has its own inherent

Attributes have their own inherent behavior, these are things inherent in the matter itself, and the object-oriented method is to describe this

Stable things. The function-oriented modular method It is a connection between things, it can't see the concept of things in their eyes.

It only pays attention to the function, have we always think about this function when the module is divided? Few people

I think, a function is a function, this feature must contact some things, we have not to grasp the things itself.

Only consider how to interact between things. To put it bluntly, this is called this at the end, and it is also called an emergency, because

In order not our wisdom, just because we don't think much about one step. Functional structured methods because it pays attention to

The connection between things, while the contact is changed, the things itself may not change, and the connection is very likely to change

If you change, contact it, that is another world, that is another function. If we use object-oriented methods, I

They can change to death, as long as the things are described in advance, we have to change these classes.

Just reuse our class libraries, and process-oriented methods because it constructs a unstable world, so a little small

Changes may also cause the entire system to change. However, the object-oriented method still has problems, and the problem is the method of reuse. take

The basis of the building block software constructor is to have many a variety of reusable components, modules. What we first think of

Class library, because the direct result produced by the object-oriented method is a number of classes. But reuse of class libraries is based on source code.

, This is its significant defect. First, it limits the programming language, your class library is always written in a language, then you can't

I have used it in other languages. Second, you must recompile each time, only compiled with your own code.

Generate an executable. This is nothing, the key is that your EXE has been generated after the development is complete, if

At this time, your class library provides vendors to tell you that they have done a new class library, and the function is more powerful, and you are

I want to use this new version of the class library into your own program, then you must recompile, rebugging! This is ideal from us

The building block software constructor has a certain gap. It is very convenient to take a module and change a new module in our idea. But now it is necessary to recompile, but also risks, because You may have to change your own

Code. Another reuse method naturally thought of the way is a DLL. Windows is a DLL everywhere, it is Windows

The foundation, but the DLL also has its own shortcomings. Summarize it at least four points. (1) Function is renamed. DLL is one

One function, we call functions through the function name, what should I do if there is a renameful function in the two DLLs? (2) each compilation

The name is incompatible with the name of the C function. For C functions, the compiler is generated according to the function of the function.

The name of the DLL reservoir is this modification, but different compilers produce modified methods are different, so you are in VC

The DLL written in the BC can not be used in the BC. However, you can also use extern "C"; to emphasize the use of standard C function characteristics, close

The modification function, but it also lost the C overload polymorphism. (3) path problem. Put it under your directory, others

The procedure can not be found, put it in the system directory, may have a problem. And true components should be available anywhere

You can even don't need to consider this problem at all, users don't need to consider this problem. (4) DLL and EXE dependence. We generally use hidden

The way the way is connected, it is programmed to indicate what DLL, this way is simple, it is tied to DLL when compiling

It is together. If the DLL releases a new version, we must also re-link once, because the address of the function in the DLL can be

Can have changed. The DLL disadvantage is the advantage of COM. First we have to grasp a point, COM and DLL are

Based on binary code reuse, it does not exist when the library is reused. Another key point is that COM itself is also a DLL,

Beneficial to be ActiveX control. ICX is actually a DLL, so the DLL has a great advantage in reuse, but we

By formulating complex COM protocols, the mechanism of COM itself changes the reuse method, with a new method to use DLL, come

Overcome the defects in which the DLL itself, thereby achieving higher levels of reuse methods. COM has no rename, because it is not a pass

The function name is used to call the function, but through the virtual function table, there is naturally no function name modification. Path problem is not repusive

Because it is to find the component by checking the registry, where it is possible, even in other machines. Nor

Considering the dependence of EXE, both of them are loosely combined, and can easily replace a new version of the assembly.

This, and the application is mixed.

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

New Post(0)