----

Wednesday, October 9, 2013

Prototype Design Pattern Example

Prototype Design Pattern: Prototype design pattern is a creational design pattern and it is a template for creating an object from an already existing object. 

In this design pattern you use an already existing object as a prototype for creating a new object. If creating an object is time consuming, and if your application needs multiple such objects which are exactly the same or slightly different then you can use prototype pattern.

Prototype pattern can be used in transactional system, where in before performing a transaction, a clone of the prototype object is created, transaction is performed on the cloned object and if the transaction is successful  the prototype is replaced with cloned object by making the cloned object as the prototype. In case if transaction fails then the cloned object can be completely discarded.

The prototype object holds certain amount of information and if you need a similar object you can then clone the prototype object to create a similar object. If you application requires similar object but differ slightly then you can clone the prototype object and modify it slightly to fit the need of the application.


12 comments :

  1. Thanks, this is generally helpful.
    Still, I followed step-by-step your method in this Java online training
    Learn Java online

    ReplyDelete
  2. Before delving into the specifics of Softaculous license, it's crucial to grasp the fundamental role of Softaculous itself.

    ReplyDelete