A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] Help with using the Memento design pattern...

  1. #1
    Member
    Join Date
    May 2004
    Posts
    57

    resolved [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!

  2. #2
    Member
    Join Date
    May 2004
    Posts
    57
    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!

  3. #3
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    YES

    Read some Java example in Memento Pattern to understand it better.


    arkitx

  4. #4
    Member
    Join Date
    May 2004
    Posts
    57
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center