The builder mode separates the constructor and representation, and produces a corresponding object based on the customer's needs.
Originally, we implemented different specific concretebuilder Based on the builder interface to produce different objects.
However, the following example only contains one builder, so there is no interface builder or other concretebuilder.
However, the example I want to talk about today is too simple. I don't think it is the builder mode, but it is also the builder mode.
1. Intention
Separates the construction of a complex object from its representation, so that different representations can be created during the same creation process.
2. structure chart andCode
In Android, a large number of dialog box components are used. The Calling method is to build, splice, and represent them.
Builder constructs an alertdialoginstance object in create () by using settitle (), setmessage (), seticon (), and other methods.
Then the customer can show the alertdialoginstance object.
For this example, it is necessary for me to extend it to the name of the builder mode.
How to expand?
(1). create other concretebuilder
(2). create other elsedialog
(3). Step 1 determines that we 'd better create an abstract builder.
(4) create a context, inject the builder into it, and produce different dialog (or other UI) objects.
3. Results
(1). Creation Mode
(2). Different dialog can be produced, or other UIS can be produced. The production product can be very different, so there is no need to define abstract parent classes for the product.