官术网_书友最值得收藏!

  • Spring 5 Design Patterns
  • Dinesh Rajput
  • 183字
  • 2021-07-08 09:59:33

Prototype design pattern

Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype. - GOF Design Patterns

The Prototype pattern comes under the creational design pattern family of GOF patterns in software development. This pattern is used to create the objects by using a clone method of objects. It is determined by a prototypical instance. In the enterprise application, object creation is costly in terms of creating and initializing the initial properties of objects. If such a type of object is already in your hand, then you go for the prototype pattern; you just copy an existing similar object instead of creating it, which is time-consuming.

This pattern involves implementing a prototype interface, it creates a clone of the current object. This pattern is used when the direct creation of the object is costly. For example, say that an object is to be created after a costly database operation. We can cache the object, returns its clone on the next request, and update the database as and when it is needed, thus reducing database calls.

主站蜘蛛池模板: 专栏| 呼玛县| 柞水县| 闵行区| 河南省| 孟州市| 吉水县| 辉县市| 西乌珠穆沁旗| 洱源县| 兴义市| 新化县| 岳阳县| 密山市| 巴马| 敦煌市| 正阳县| 登封市| 屏东市| 西林县| 滨海县| 盱眙县| 新巴尔虎左旗| 平泉县| 莎车县| 万州区| 敖汉旗| 江油市| 阳原县| 天门市| 增城市| 轮台县| 永和县| 石门县| 新营市| 罗城| 伊吾县| 铜山县| 孙吴县| 绍兴县| 依兰县|