Developing COM Components Using VC-ATL (2)

xiaoxiao2021-03-06  45

COM basic knowledge

CoM production

The application has been developed to support corporate business operation, the application acquires data as input, processing data based on business rules, and provides data and information as output. Based on this fact, all applications have three elements:

n Users interface or presentation features, by them can enter data.

n Application logic or business rules feature, which helps implement validity, availability operations for input data.

n Data storage or data management elements, they manage data storage and recovery.

These three elements have composed of the basis for the application development model or architecture.

According to the specific use and configuration, there are three options when developing in their applications:

N single layer model

n Double Model

N three or multi-layer models

As a developer, you have to consider the following factors before determining the architecture of the application:

n scalability: This means that the application adapts to the performance of the new hardware environment. For example, when an application is moved from a single processor computer to a multiprocessor computer, it can use a newly added processor that has played a role in the new hardware.

n Availability: This means that the application meets the ability of users to increase requirements. There may be one hundred users in requesting the same data, but only a few users get data, other users show a message "Please try again later."

n Scalability: This means that applications sometimes incrementally increased feature to improve performance and provide better features to users.

n Maintenance: This refers to the ability to respond to modifying errors based on the maximized resources and maximization of the maximized resources and maximization.

n Security: This means that the application maintains data integrity and reliability. Any unrecognized user does not allow tampering data.

n Performance: This refers to the ability of the application to respond to user requests within the shortest time. Users don't wait for a long time to get request data.

In order to design a more robust app architecture, three (multi) layer architecture is used to use. The three-layer architecture is a logical application viewpoint, and the application is divided into the following three-layer logic components in this architecture:

n User Service Layer. User Service Layer manages the user interface.

N business service layer. Business service layer manages business logic implemented by the application. Business logic consists of rules that have been disposed of application. This layer encapsulates the user's logic, so users don't have to know how business logic or business rules are used. Any change in business rules will result in only changes to the business service layer, and the rest of the application remains unchanged. Business service layer implements multiple rules for applications. This layer plays the role of the user's service layer and the data service layer.

n Data Service Layer. The data service layer is responsible for maintaining data, usually RDBMS. This layer maintains the validity and integrity of the data and is responsible for adding, modifying, and deleting data from data storage.

Now, how do we do business service? The answer is COM.

What is COM?

COM is a component object model that defines a standard for development components. It defines component interaction criteria, protocol standards, and physical structures of components to ensure inter-component interference. A component is a program or binary object that performs a specific operation. Below we will understand COM from some features and features of components:

N COM is a specification. The COM specification describes the standards that must be observed to create a commonly operated component. This standard describes what COM is and how they operate, and how to dynamically update components.

N COM is a service. The COM specification is supported by a service or APIS. The COM library provides these services that are part of the Win32 platform operating system and can be used as a separate package as other operating systems.

N COM is object-oriented. COM component objects are identified, status, and behavior. N COM can easily userize and upgrade your application. The COM assembly is dynamically connected to each other, and COM defines the standards for positioning other components and identifying their functions. Therefore, components can be exchanged without having to re-establish the entire application.

N COM can be distributed. Position transparency is one of the characteristics of COM. This allows you to write COM components without having to consider their location. Components can move without requiring any changes to use their applications.

N COM components can be written in any language. Any can be used to create a COM object in handling binary languages. The language and tools that can create components include C / C , Java, Visual Basic and Visual C , etc.

So far, Microsoft advocated this COM software development model is the most in line with the current computer industrial software production. Many technologies of Microsoft, such as ActiveX, DirectX, and OLE, etc. are established based on COM. And Microsoft developers also use COM components to customize their applications and operating systems. Under the COM architecture, programmers can develop a wide variety of features, and then set them as needed to form complex application systems. The benefits of this result are many aspects:

n The biggest advantage of using components is first in all, inserting or unloading the application system, is a real software module plug and play. Components can be replaced by new components in the system without reinprinting or compiling applications, so that the system is upgraded and customized. The biggest advantage of this is that the programmer can use the latest components written out to replace some other parts of the entire system to replace some old components and other parts of the system. Applications can continue to replace the old components with new components and become more and more robust. Moreover, users can also establish a new application quickly with existing components. (Note: Alternative components are custom components, not components in the runtime library of COM itself)

N binary reuse. According to COM specification, components can be reused using the same component in multiple applications.

n distributed application. With COM / DCOM component technology, it is convenient to extend the application system to the network environment.

N COM is independent of language. You can write COM components in a variety of languages, such as Delphi, Visual Basic ... This makes programmers to write components with their own language, without learning other dedicated languages ​​to write components.

N COM is not related to the platform. It can be conveniently transplanted with different platforms using the written components.

In the three-layer architecture, create a COM component to implement the business service layer. Because COM components can interact, each component must strictly implement the complete standards developed by COM.

COM has a significant advantage in providing three unique features:

n Call the binary standard between components. COM ensures that clients developed by Visual Basic and developed with Visual C and runs complete binary compatibility between components of the Solaris or Mac server. Therefore, COM allows you to create code modules independent of language and operating systems.

n code reuse. Because the interface is documentation, the code for creating an object can be used by different customers.

n version control. COM-based components are self-version. In impact, new features can be added to the component without affecting users who have used this component (/ customers)

It can be seen that the COM component is truly object-oriented, providing simple userization, providing address transparency and writing in any language. It is because COM has these advantages, COM has been widely used.

COM components are truly object-oriented

n Traditional object-oriented programming

Object-oriented programming is a long-awaited concept that is recognized by the majority of programmers and industrial. Object-oriented programming language allows developers to write programs in accordance with the model of people thinking about people in the real world, which allows developers to better express the objects existing in real realism, so that the development code is simple and easy to maintain. Object-oriented languages ​​have the following three most important concepts: n Packages (Encapsulation) emphasizes the implementation details of hidden objects, and the user uses only objects that define the well interface.

n Inheritance new objects can utilize the functions of the old object.

N: Polymorphism demonstrates a variety of different behaviors based on the objects used.

From the overall view of the program, object-oriented programming to the user is the source code reuse, which is extremely important for improving the efficiency of writing programs. However, the sharing and reuse of the code is still available in practice, such as version upgrades, changes in interface [1], shared code between different programming languages, etc. There is no corresponding answer for these difficult object-oriented programming methods, which is the background of the component object model.

Componiment programming

It is a fundamental difference with the traditional object-oriented model. The focus of the traditional object-oriented programming model is the source program and the system analysis and design process. Object-oriented is still reused based on source code, is not a true object orientation. Instead, the concept of COM components emphasizes how large software systems make up the overall application architecture of different small components.

Decomposing engineering into logical components is the basis for component analysis and design, which is the basis of component software. The component software system consists of a reusable binary software component module, and only a quite small change can be combined with the component modules from different developers. It is particularly important that such a combination does not require source code, and does not need to be recompiled. Components are communicating based on binary specifications, which is called binary reuse. The component module is independent of the programming language, and there is no definition from each other in addition to the standard method between the client programs and components.

Components can be divided into different types, including visual components such as buttons or list boxes; feature components such as printing or spelling checks. For example, a component-based architecture can provide a mechanism in inserting multiple developers's spell check components into another developer's word processing application so that users can easily select and replace the word processing software according to their own preferences.

COM allows you to create separate and reusable components that are united to form an application. In COM, the interaction between components is based on a Client / Server model (ie, client and server model). Based on this model, COM components can be classified as:

n Client uses features provided by other components.

n Server has a predetermined functionality that may use other components.

The client and component program are relative, and the function request call is a client program, and the component program is requested. The component program can also be used as a client to call other component programs, that is, the COM server that provides services to the client may be the customer itself. It is this role transition and mutual call relationship to make the component program eventually constitute a software system.

Server components Type

COM is designed to allow components to communicate with each other regardless of their address. For example, the user interface component will preferably be positioned close to the client. On the other hand, the components that provide remote data statistics will penetrate the data that will be operated may be positioned on one separate computer. COM server components can be divided into three categories:

N Processes Internal Components Performed Server [2] is a component that is loaded into the client's process space, that is, the client and component program in the same process address space. It is desirable to have a large amount of data transfer operations between the client and the server components. The server will be loaded faster in the process. Because it takes up the same address space, it can communicate with the client faster. The internal server is implemented by using the component as a dynamic connection library (DLL). The DLL allows specific sets to store files that are separate from executable, DLL-based files. Only when the program needs them, the DLL loads it into memory, and the client is loaded into the component program to call the component program after the component program is loaded. n Local (ie, processes) Component Component Components Refers to the client program and component programs in different process space addresses. Process server is ideal for components that need to run independent processing spaces or as a stand-alone client application. The type of such server itself is Exe, so it has an independent process. Since the data must be moved from an address space to another, these servers will be much slower. Since the process server is executable, they run in their own thread. When the client code is being executed, the client does not lock the server. Process server is also ideal for components that need to be independent applications. For example, the application of Microsoft Internet Explorer is an example of a local server. The client and server communication is performed through the communication protocol within the process, and this communication protocol is IPC.

n Remote Components The remote server is similar to the local server, except that the remote server is running on a separate computer through the network. This feature is implemented using DCOM. The advantage of DCOM does not require any special programming to make functions. In addition, the server and client communication are performed through the RPC communication protocol.

For these three different server components, the inner way of the client and component program interaction is completely different. However, for the functionality of the functionality and processes, from the perspective of programming, the client program is used by the same method, and the client does not need to make any modifications.

Author Blog:

http://blog.9cbs.net/callzjy/

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

New Post(0)