Java uses the prototype pattern to show the detailed explanation of daily life application cases
This article illustrates how Java uses prototype patterns to show daily life. Share with you for your reference, as follows:
Model definition
Specify the kind of objects to create with prototype instances, and create new objects by copying these prototypes.
Two. Example of model
1 mode analysis
We borrow the first mock exam daily to illustrate this pattern.
2 plot analysis chart
3 prototype mode static modeling
4 code example
4.1 prototype establishment
4.2 create an abstract factory to generate prototype objects
4.3 create a specific factory to generate prototype objects
4.4 daily work scenario Display
Operation results
3、 The design of this model is original
1 when cloning an object, the construction method of the object does not perform 2 shallow copy and deep copy
4、 Use occasion
1. The process of generating pairs is complex, and initialization requires many resources. 2. When you want the framework prototype to be separated from the generated object. 3. When the same object may be called and accessed by other callers at the same time
For more information about Java algorithms, readers who are interested can see the topics on this site: Java data structure and algorithm tutorial, summary of Java DOM node operation skills, summary of java file and directory operation skills, and summary of Java cache operation skills