vendredi 4 octobre 2019

Performance of Cloning (either by Cloneable Interface or Copy Constructor) a object vs Creating a new object in Prototype Pattern

Recently while learning about Design Patterns I learnt that the Prototype Pattern is very useful and performance efficient in scenario's where huge number of Object creation is needed, and that Prototype Pattern minimises the expense of too many object creations by making use of Cloneable interface or Copy Constructor in Prototype Pattern.

But I would like to know how does cloning or copying an object more efficient than creating a new object. A JVM level explanation would be great.

And is this the only reason Prototype Pattern is made used?

Aucun commentaire:

Enregistrer un commentaire