Thoughts on the abstract process of the general order Generation Process

Source: Internet
Author: User
Think about the abstract process of the general order generation process. Generally, e-commerce websites will have the order generation business. Recently, they are responsible for this business, so I have taken good care of this business. In fact, whether it is the order part of the Business Code, or other part of the Business Code. I. Thinking about the abstract process of the general order Generation Process

Generally, e-commerce websites have an order generation business. Recently, they are responsible for this business, so they have taken good care of this business.
In fact, whether it is the order part of the Business Code, or other part of the Business Code. A code that accidentally writes a stream program. I personally think there are several points for writing the code of a stream program:

  1. The code is filled with many comments. The comments are written as follows: 1, 2, 3, 4, 5, 6.
  2. There is no hierarchy in the Code. For specific hierarchy, see business hierarchy. Another thing we need to design is abstract consistency.
  3. The code is not intrusive. The specific embodiment is one thing that will be interspersed in many places. For example, the Order involvesPostageThe calculated postage value is distributed throughout the order process. The downside is that after a problem occurs, you cannot find out where the problem occurs.

The order process is based on the general process. Several steps will be generated

  1. Calculate the discount (including activities and red packets)
  2. Calculate postage
  3. Generate payment information
  4. Generate order
  5. ......

First, analyze the entire order process and find that it is actually a black box. After a batch of parameters are passed on the page, we encapsulate them and then drop them into the black box. The generated order entity is displayed in the black box.
First, we establish a high-level abstraction for the entire process. That is:

    public interface Builder{        public void do(Context context);    }

In this way, each part is doing its own thing. If it involves communication with other modules, you can use this contextContext. In this way, modularization can be achieved to a large extent. As for the smaller abstraction, we can also abstract more Builder Based on different levels to make our code modularized.
As for how to connect these Builders. At the beginning, I thought this process could be seen as an order entity building process.Builder ModeBut I found that all these things are put in a class, which is too laborious for maintenance, so I used it later.Responsibility Chain Model(Similarstruts).

After this abstraction, you will find that. Every class is doing its own thing, and there is no need to write a lot of comments to comment out the entire process. For the process extension, because the entire shelf is there, if it is an extension process, it is OK to add a node to the existing chain. If it is an extension within the business, you only need to expand in the corresponding class and will not involve other classes.

Here I wrote aboutBuild in ModeAndResponsibility Chain ModelI am going to discuss some things about the design pattern in the next question.
I hope you can give us some advice.

Reply: Thoughts on the abstract process of the general order Generation Process

Generally, e-commerce websites have an order generation business. Recently, they are responsible for this business, so they have taken good care of this business.
In fact, whether it is the order part of the Business Code, or other part of the Business Code. A code that accidentally writes a stream program. I personally think there are several points for writing the code of a stream program:

  1. The code is filled with many comments. The comments are written as follows: 1, 2, 3, 4, 5, 6.
  2. There is no hierarchy in the Code. For specific hierarchy, see business hierarchy. Another thing we need to design is abstract consistency.
  3. The code is not intrusive. The specific embodiment is one thing that will be interspersed in many places. For example, the Order involvesPostageThe calculated postage value is distributed throughout the order process. The downside is that after a problem occurs, you cannot find out where the problem occurs.

The order process is based on the general process. Several steps will be generated

  1. Calculate the discount (including activities and red packets)
  2. Calculate postage
  3. Generate payment information
  4. Generate order
  5. ......

First, analyze the entire order process and find that it is actually a black box. After a batch of parameters are passed on the page, we encapsulate them and then drop them into the black box. The generated order entity is displayed in the black box.
First, we establish a high-level abstraction for the entire process. That is:

    public interface Builder{        public void do(Context context);    }

In this way, each part is doing its own thing. If it involves communication with other modules, you can use this contextContext. In this way, modularization can be achieved to a large extent. As for the smaller abstraction, we can also abstract more Builder Based on different levels to make our code modularized.
As for how to connect these Builders. At the beginning, I thought this process could be seen as an order entity building process.Builder ModeBut I found that all these things are put in a class, which is too laborious for maintenance, so I used it later.Responsibility Chain Model(Similarstruts).

After this abstraction, you will find that. Every class is doing its own thing, and there is no need to write a lot of comments to comment out the entire process. For the process extension, because the entire shelf is there, if it is an extension process, it is OK to add a node to the existing chain. If it is an extension within the business, you only need to expand in the corresponding class and will not involve other classes.

Here I wrote aboutBuild in ModeAndResponsibility Chain ModelI am going to discuss some things about the design pattern in the next question.
I hope you can give us some advice.

You can use apple-touch-startup-image to set the startup

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.