Teach you how to read a blog to understand the design pattern - prototype pattern

Teach you how to understand the design pattern of a blog----prototype pattern

what: what

Prototype mode:

It is used to create duplicate objects. It does not need to set and get attributes one by one without affecting performance. The object generated by the prototype mode is not the same instance as the original object, and their addresses are also different (different from direct copying );

Commonly used application scenarios:
  1. When a class needs a large number of repeated objects, the prototype mode is the best choice, because the prototype mode copies the object at the memory level (bytecode level, without using the construction method). The performance of this object is much better than direct new.
  2. When you need most of the public information of an object and a small number of custom fields for custom design, you can also use the prototype mode to copy the original object.

Guess you like

Origin blog.csdn.net/weixin_37766296/article/details/107049718