Last week I tried to learn Memento Design Pattern, thought to share my knowledge with you all.The Memento pattern is a design pattern that permits the current state of an object to be stored without breaking the rules of encapsulation. The originating object can be modified as required but can be restored to the saved state at any time.
// The 'Caretaker' class class ProspectMemory { private Memento _memento; // Property public Memento Memento { set { _memento = value; } get { return _memento; } } }
/*OUTPUT :Name: Noel van HalenPhone: (412) 256-0990Budget: 25000Saving state --Name: Leo WelchPhone: (310) 209-7111Budget: 1000000
Restoring state --
Name: Noel van HalenPhone: (412) 256-0990Budget: 25000*/
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: