PHP design pattern prototype mode, design pattern prototype
Prototype patterns are similar to engineering patterns, and are used to create objects.
Unlike the implementation of the engineering pattern, the prototype pattern is to create a good one prototype object and then a bronze drum clone prototype object to create a new object. This eliminates the duplication of primitive operations when the class is created.
Prototype mode is suitable for the creation of large objects. Creating a large object requires a lot of overhead, and if new is expensive every time, the prototype mode requires only a memory copy.
index.php
$prototype New Baobab\canvas (); $prototype, init (); $canvas 1 Clone $prototype ; $canvas 1->rect (3,6,4,12); Draw ( $canvas 1); $canvas 2 Clone $prototype ; $canvas 2->rect (3,6,4,12); $canvas 2->draw ();
http://www.bkjia.com/PHPjc/1105141.html www.bkjia.com true http://www.bkjia.com/PHPjc/1105141.html techarticle PHP Design pattern prototype mode, design pattern prototype prototype mode and the role of engineering mode is similar, are used to create objects. Unlike the implementation of the engineering model, the prototype model is created first ...