DEV Community

Discussion on: The Prototype Design Pattern C# .net core

Collapse
 
diagonallay profile image
DiagonAllay

It is feel like singleton but in another way

Collapse
 
gary_woodfine profile image
Gary Woodfine

It is no way like a singleton at all. Singleton by design is about limiting you class to only one instance and only one. Prototype enables making multiple copies of your class.

Collapse
 
diagonallay profile image
DiagonAllay

Sorry for misunderstand... I wonder what is the diffrent between multiple copies that changing in one instance of them will affect the other... While you just can use singleton instead

Thread Thread
 
gary_woodfine profile image
Gary Woodfine

prototype pattern lets you create new instances of a class by duplicating an already existing instance. You create new instance of class by copying an existing class.

Singleton pattern ensures there is only 1 of class. You do not create new instances of a singleton class, you only have 1 instance