An overview of HTTP system based on business class communication

Source: Internet
Author: User

An HTTP system based on business class communication, as long as it consists of HTTP server and HTTP client. This series of discussion is based on the implementation of Delphi, in fact, can be extended to other language platform above. Interested friends can try. In Delphi, the server can use Tidhttpserver directly, the client will be able to use the tidhttp directly to complete the process of communication. Yes, that's it. Simply, these two controls form a business system that can be very large in volume. Because HTTP is stateless, the client requests the server directly, and the server returns the relevant content to the client. If this is not a long connection, the connection to the server will be disconnected directly. Therefore, for the regular business processing, the service side can still cope with the surplus.

Of course, the above two controls only constitute the basis of data communication, as for the way of communication transmission, do not need me to say, we should be very clear that the most efficient way is definitely directly transmitted byte stream. So since the business class is the basic unit of the system, then there is a problem, how to convert the business class from object to byte stream? Well, eye-catching or seasoned friends will think of encode and decode these encoders and decoders the first time. That's right, encoders and decoders!

Encoders and decoders are common to both the server and the client, and can be encoded directly with a standalone unit, but can also be written directly on the base class of the business class (this approach is less consistent with object-oriented programming methods, and is recommended for encoding and decoding by the factory class. There will be an introduction in the following implementation section). Their role can be referenced by:

  

Then the transfer of business class is not a problem, then the business class processing problems. As a large business processing system, the number of business classes is certainly not a small number, if each business class to build a map so it is a very tedious thing. To solve this tedious problem, the system uses a common IOC pattern in the Web.

What the? What is the IOC? This one...... I will simply introduce, if not understand, please self-degree niang or brother Gu. The IOC English name is inversion of control, translated into Chinese is controlled inversion, in fact, this is still not correctly describe the role of the model in this system, in order to more intuitively describe what is the IOC, I give an example to illustrate it.

In general, the CS system, especially in the HTTP system, is the command and response mode. It is most normal for the client to request what commands to respond to on the server. However, as the system functions more, the definition of the command is a headache, the more commands, the greater the chance of trouble, that is, the more difficult to maintain the back. Because, to maintain the relationship between the command and the corresponding function process, each command corresponds to a Function procedure, which is unthinkable if the command is more.

So the IOC has solved this problem completely and perfectly, the IOC is actually the equivalent of having all the commands divided into different business classes to maintain the correspondence and implementation of the command and function processes, so that our modifications and maintenance are more purposeful and do not need to maintain a large control relationship table. It is equivalent to not using the business class is to find corresponding matching command, but through the program decoding after the restoration of the business class directly to find the corresponding command. It's just a little bit easier to say that you didn't go to him, he came to see You (O (∩_∩) o~). So you might think, bloggers, you've said so much in Jiliguala that you still don't understand what the IOC is. Well, don't worry, in the detailed implementation, I will also give a detailed introduction of his implementation and ordinary command map which is better or inferior. But then again, with my writing level, if you see here that I can understand what the IOC is, you must have known what the IOC was. So if you don't understand, don't worry, be decisive and ignore it.

The IOC solved the problem of a large backlog of commands. Then there is the business of how to do it. It's a little complicated to say that it's a little complicated. How to say, first in order to be able to deal with the business more quickly, there are several pools are essential, one is the thread pool, one is the memory pool, and the other is the database connection pool. But a pond may say a few days also say, I also did not intend to explain, this piece almost online a grab a lot, you crossing if interested can refer to the source code reference after release.

This article is mainly about the service side of the system to achieve the approximate direction, listing a few key terms, and then has been in the flicker. If you have not been fooled, please pay more attention to the future of this series of post.

  

An overview of HTTP system based on business class communication

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.