|
-
[RESOLVED] Help with using the Memento design pattern...
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...
He took daddy's umbrella!
-
Hmm, looks like the example I read was a bad one. Seems that the main class should instantiate both, and the caretaker should not instantiate its own originator class (it should just provide setMemento/getMemento methods).
He took daddy's umbrella!
-
YES
Read some Java example in Memento Pattern to understand it better.
arkitx
-
Yeah, the code example i was reading wasn't very clear.
This was a far better explanation (As3): http://www.as3dp.com/2008/01/actions...-saved-states/
He took daddy's umbrella!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|