Prototype mode (PROTOTYPE)
The prototype mode belongs to the creation mode of the object. By giving a prototype object to indicate the type of all objects created, and then creating more objects of the same type with the method of copying the prototype object. This is the intention of the prototype model.
Structure of the prototype pattern
The prototype pattern requires that an object implement an interface that can "clone" itself, so that a new instance can be created by copying an instance object itself. Thus, by creating a new object from the prototype instance, it is no longer necessary to care about the type of the instance itself, as long as the method of cloning itself is implemented, this method can be used to acquire new objects without having to create them through new.
The prototype mode has two forms: (1) The Simple form (2) Registration form, these two forms of expression are only the different realization of the prototype pattern.
Prototype mode in simple form
Java design mode-prototype mode