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.
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
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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.
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
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