Design Pattern The 3-builder generator _ design pattern and architecture of reading notes

Source: Internet
Author: User

BUILDER (builder)--Object creation mode

1. Intention: Separate the construction of a complex object from its representation, so that the same build process can create different representations.


2. Applicability: Applicable to the use of builder mode,

A. When creating complex objects should be independent of the components of the object and their assembly methods.

B. When the construction process must allow the constructed object to have a different representation


3. code example:


The Mazebuilder class defines the following interface
class mazebuilder{public
       :
            virtual void Buildmaze () {}
            virtual void Buildroom ( ) {}
            Virtual maze* getmaze ();
       Protected:
             Mazebuilder ();

Use builder
maze* Mazegame::createmaze (mazebuilder* builder)
{
     Builder. Buildmaze ();
     Builder. Buildroom ();
     Return builder. Getmaze ();
}


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.