Prototype Design pattern

Prototype design pattern comes under creational design pattern. This pattern is very easy to understand.

Prototype design pattern provides duplication of an existing object. This can be achieved with Object class clone method. Object creation with new operator is time consuming and costly in an Enterprise projects. So instead of creating object with new operator (which is costly in creation of an object), create object with clone.

Steps to implement Prototype design pattern:

1)  Create an abstract class with clone method

2)  Create concrete classes extending Subscriber abstract class.


3) Create a class to get the cloned objects

4) PrototypeDemo uses the SubscriberCache to get the cloned objects of Subscriber.



Posted in designpatterns and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.