2015年12月1日 星期二

Prototype

Prototype:( copy)


Def: 

  • Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. 
  • Co-opt one instance of a class for use as a breeder of all future instances. 
  • The new operator considered harmful.
當需要產生的物系眾多時
可以考慮用這個pattern
會比用new  來的快

在factory pattern 及object pool 中
可以考慮這個pattern
來增加程式執行速度

沒有留言: