Introduction and application of IOU design pattern

Source: Internet
Author: User

Principle

IOU thought is one of the effective ways to deal with the daily debt relationship, namely:

The debtor issues IOU debt vouchers to creditors through a reliable third party custody account;

The debtor terminates the IOU debt by submitting the results to a third party custody account;

The creditor carries out the creditor's right through the third party custody account with this IOU debt certificate and proceeds to redeem.

The debt relationship between debtors and creditors enables maximum separation and decoupling of time and space through reliable third party custody accounts.

IOU design mode is the application of IOU thought in the field of software design, first proposed by Allan Vermeulen in 1996. In the field of software design, the debt relationship occurs between the method caller and the method body, and the debt object is the return result of the method. The normal method's invocation model is that the method body executes synchronously and then returns the result, and the caller must wait for the result to return before executing. In IOU design mode, the method body returns an IOU object immediately, and the promised IOU object will eventually be terminated, and the caller can redeem the result after the IOU object is terminated. During this time, the caller can continue to perform other worthwhile transactions without waiting, thus achieving the goal of increasing the concurrency and asynchrony of the program as a whole.

The IOU design pattern is completely independent of any asynchronous mechanism, and the provider of the IOU object can choose any effective way to perform the service and eventually terminate the IOU object, such as enabling independent thread/Process execution, driving asynchronous event generation, using remote method calls, or waiting for user terminal input, and so on. This is an important factor in the general applicability of the IOU model.

Analysis and implementation of IOU model

The IOU mode is mainly IOU (debt voucher) and escrow (third party custodian account) two objects, the actual use of the pattern will also involve Caller (caller), callee (callee) and Asyncservice (asynchronous services) and other objects.

Sequence diagram

Through sequential graphs, the reader can establish a preliminary impression of the use of the IOU pattern.

Figure 1. IOU Pattern sequence Diagram

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.