Prototype (prototype ):Use a prototype instance to specify the type of the object to be created, and copy the prototype to create a new object.
The prototype mode is used when a system is created, constructed, and expressed independently of its products;
When the class to be instantiated is scheduled at the runtime, for example, through dynamic loading, or to avoid creating a factory class level parallel to the product class level;
When an instance of a class can only have one of several combinations of different States. Creating prototype and cloning them may be more convenient than manually instantiating this type with the appropriate state each time.
Personal Opinion:
To put it bluntly, an icloneable interface is implemented, which contains a clone method that allows you to build a superficial copy of the object through the clone method.
The so-calledA superficial copy indicates that if a field is of the value type, the field is copied one by one. If the field is of the reference type, the reference is copied, but the referenced object is not copied.. Therefore, if a field of the reference type exists in the class, only one reference of the method can be copied when memberwiseclone () is called to implement the clone interface method.
If you perform deep replication, a new object is also specified for the reference type. The framework does not provide a method for deep replication. You need to implement it yourself. Similar to dataset's clone () and copy () methods, one is superficial replication, and the other is deep replication.