Design Patterns curriculum design model prototype model to explain succinctly 9-1

1 lectures

1.1 Definitions

1.2 Types

1.3 Features

1.4 application scenarios

1.5 advantage

1.6 shortcomings

1.7 Extended

 

 

1 lectures
1.1 Definitions

Definition: Prototype instance of the specified type to create an object, and create new objects by copying the prototype

Own understanding: Clone to clone an object

 

1.2 Types

Type: Creating type

 

1.3 Features

Not need to know any details of creation, do not call the constructor.

If the method to implement copy, the method is preferably covered Object (deep clone, see the next section)

 

1.4 application scenarios

◆ class initialization consumes more resources
a new object is created requires a very tedious process (data preparation, access rights, etc.)
◆ constructor is more complex
when the loop body production ◆ large number of objects

 

1.5 advantage

◆ prototype model performance than direct new high-performance object
◆ simplify the creation of

 

1.6 shortcomings

◆ must be equipped with cloning method
◆ When cloning complex objects or object cloned complex transformation, easy to introduce risk
deep copy and shallow copy to be used properly

 

1.7 Extended

Shallow clone and a deep clone

 

Guess you like

Origin www.cnblogs.com/1446358788-qq/p/11456714.html