Design Pattern creation pattern Builder

Source: Internet
Author: User

Code download

1. Concept
Separates the construction of a complex object from its representation to make the same construction
The process can create different representations. Such a design pattern is called the builder pattern.
Key Points

1). Builder: Specifies an abstract interface for each part of a product object.
2) concretebuilder: implements the builder interface to construct and assemble each part of the product, define and define the representation it creates, and provide an interface for retrieving the product.
3) Director: constructs an object using the builder interface.
4), product: indicates the complex object to be constructed. Concretebuilder creates an internal representation of the product and defines its assembly process, including the class that defines the components, including the interfaces that assemble these components into the final product.
2. Class Diagram
Taking nvwa as an example:

3. Test code

Persondirector Pd = new persondirector ();
Person PS = Pd. constructperson (New manbuilder ());
This. Text = ps. Head + "-" + PS. Body + "-" + PS. Foot;

Code download

 

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.