0% found this document useful (0 votes)
4 views5 pages

Understanding the Prototype Pattern

The prototype pattern refers to creating duplicate objects while maintaining performance. It involves implementing a prototype interface that tells an object to clone itself. This pattern is useful when directly creating an object is costly, such as after a database operation. It allows caching the object and returning clones on subsequent requests while updating the database as needed to reduce database calls.

Uploaded by

Ayush Khunteta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Understanding the Prototype Pattern

The prototype pattern refers to creating duplicate objects while maintaining performance. It involves implementing a prototype interface that tells an object to clone itself. This pattern is useful when directly creating an object is costly, such as after a database operation. It allows caching the object and returning clones on subsequent requests while updating the database as needed to reduce database calls.

Uploaded by

Ayush Khunteta
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

PROTOTYPE PATTERN

Devashish Mahbubani Y13UC084


Kushal Mishra
Y13UC151
Shubham Gupta
Y13UC276

DEFINITION

Prototype pattern refers to creating duplicate object


while keeping performance in mind. This type of
design pattern comes under creational pattern as
this pattern provides one of the best ways to create
an object.

This pattern involves implementing a prototype


interface which tells to create a clone of the current
object. This pattern is used when creation of object
directly is costly.

EXAMPLE

An object is to be created after a costly


database operation. We can cache the
object, returns its clone on next request
and update the database as and when
needed thus reducing database calls.

CLASS DIAGRAM

When to use Prototype Pattern:


[Link] Prototype Pattern when creating an instance of a given
class is either expensive or complicated (or) when a system
must create new objects of many types in a complex class
hierarchy.
[Link] there are many subclasses that differ only in the kind
of objects, A system needs independent of how its objects are
created, composed, and represented.
Disadvantages:
Drawback to using the Prototype is that making a copy of an
object can
sometimes be complicated.

You might also like