Java design mode ------ builder mode, java design mode ------

Source: Internet
Author: User

Java design mode ------ builder mode, java design mode ------

Builder mode separates the construction of a complex object from its representation, so that different representations can be created during the same construction process.

Class Diagram

 

Description

Builder: defines a Builder abstract class to standardize the construction of each component of a product object. This interface specifies the parts of the object to be created, and does not involve the creation of specific object parts.

ConcreteBuilder: inherits the Builder to create specific parts of an object based on different business logic. After the construction process is complete, provide the product instance.

Director: Call a specific builder to create all parts of an object. The supervisor does not involve information about a specific product. Instead, he is only responsible for ensuring that all parts of the object are completely created or created in a certain order.

Product: the object to be created.

The builder mode only has one "ctor class" role more than the factory mode.

Application scenarios

Taking car production as an example, the builder is responsible for producing all parts of the car, and the conductor is responsible for directing the builder to assemble the car according to the process.

 

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.