Hello!
[First of all, apologies if this is in the wrong forum. Not sure where it should go...]
I understand that the memento pattern is made up of the originator, caretaker and memento classes, but I'm confused where the originator should be instantiated.
Should only the caretaker instantiate the originator (so all control goes via the caretaker) i.e. my main class creates the caretaker which then creates the originator? (This is the example I have seen in the book I am reading).
Or should my main class instantiate both, and pass the instance of the originator to the caretaker? This would mean the main class can interact with the originator as normal, and then use the caretaker to save states as required.
Thanks in advance...




Reply With Quote
