Statement: The reference material for this series of blogs is "Dahua Design Pattern", written by Cheng Jie.
Use prototype instances to specify the types of objects to be created, and create new objects by copying these prototypes. Prototype mode allows an object to create another customizable object without knowing any details of how to create it . By passing a prototype object to the object to be created, this object is to be created. Objects are created by requesting a copy of the prototype object . The main problem it faces is the creation of "some objects with complex structures"; due to changes in requirements, these objects often face drastic changes, but they have relatively stable and consistent interfaces. H p In PHP, the class has implemented the prototype mode. PHP has a magic method __Clone () method, which will cloning a object. Take a look at the UML class diagram:
Role analysis:
1. Abstract prototype provides a cloned interface
2. Specific prototype and interface to implement cloning
Specific code:
[php] view plain
copy print
?
/**Abstract prototype class
* Class Prototype