Memento Design Pattern

[ad_1]
Get the Copy and Paste Code:

Welcome to my Memento Design Pattern Tutorial! The Memento design pattern provides a way to store previous states of an Object easily.

It has 3 main classes:

1. Memento: The basic object that is stored in different states. 

2. Originator: Sets and Gets values from the currently targeted Memento. Creates new Mementos and assigns current values to them. 

3. Caretaker: Holds an ArrayList that contains all previous versions of the Memento. It can store and retrieve stored Mementos.

All of the code is above to help you learn.


Posted

in

by

Tags:

Comments

40 responses to “Memento Design Pattern”

  1. Shimon Balzera Avatar

    Clear and clean, THANK YOU VERY MUCH.

  2. Siraj Elsheikh Avatar

    Will Hello internet and welcome here if your lecturer can't explain this to you

  3. kiran Mohan Avatar

    this is simply awsome

  4. Tobias Franke Avatar

    What is the purpose of the Memento class?
    It just stores a simple string. So why don't you use a String object and leave out the Memento class entirely?

  5. ReynaldAdolphe Avatar

    Do you have a version of this in C#?

  6. Lauris Tamo Avatar

    Why ? why all these swings and JElements ? 🙁 I just try to understand pattern 😐

  7. PACKARD Josy Avatar

    wow, what a voice, is it your real one, or do you use any kind of mic app ?
    by the way, thanks for the tutorial, I hate java and patterns, but I have to do some for my diploma, without you, I was so dead !

  8. ibn mrabet achraf Avatar

    hey you re tuto are great, but can we get the source code pliize?

  9. Chris VS Avatar

    Hi Derek, as usual this is very useful and so well explained!!! I just noticed that when I tried to make it executable using your video "MAKE JAVA FILES EXECUTABLE" no 88 it won’t work… I also tried with few other exercises and it's the same unlucky result. Will you explain how to complete this please? Many thanks in advance and take care.

  10. wjrasmussen666 Avatar

    Very well done.

    Wondering, if this was a video game could it be used to save game state to a file?

  11. Karthik Rangaraju Avatar

    lovely presentation of Memento design pattern ! 

  12. kooboolc Avatar

    Love your videos.
    I think that You shouldn't fuzz design pattern with Swing components though. It makes pattern harder to understand. Leave it for java specific tutorials 🙂

  13. Derek Banas Avatar

    Speed is the only reason. C++ is extremely fast in comparison to Java. I use C for hardware / electronics related projects.

  14. Iam Djalas Avatar

    lol I never been to Walmart.
    Why would u use C++ instead of Java Derek?

  15. Derek Banas Avatar

    I'm sorry, but I haven't been in Walmart for over 10 years. I have no idea what their checkout looks like. I'm guessing it was programmed in C++ because that is probably what I'd use.

  16. Iam Djalas Avatar

    thanks. lk u know walmart self service checkouts??what did they use to create the GUI?

  17. Derek Banas Avatar

    For GUI development I use Swing and the Standard Widget Toolkit

  18. Iam Djalas Avatar

    is that the best API for GUI?

  19. Derek Banas Avatar

    You're very welcome 🙂 Ill cover JavaFX ASAP.

  20. Federico Jimbo Smithson Avatar

    Wow thanks again Sir Derek. Please make some tutorials for JavaFX. I would like to learn GUI programming

  21. tomyvarghese Avatar

    Thank you for clarifying Derek – i will check out the refactoring tutorials..

  22. Derek Banas Avatar

    Yes you are correct. I cover how to eliminate the if statements in the refactoring tutorials

  23. tomyvarghese Avatar

    just getting into Design Patterns ..and i love your videos Derek !! ,although i am from an C# background
    ..in the Memento pattern example , noticed a lot of "if" statements, "if" statements usually point to a need for another design pattern (?)..usually..sometimes …do correct the statement , i am kind of a newbie to Design Patterns

  24. Derek Banas Avatar

    You can pretty much watch them in any order.

  25. Garba M Rabiu Avatar

    is one expected to follow these as presented here or you can watch in any order you like

  26. Derek Banas Avatar

    Thank you 🙂 I did make an objective c tutorial years ago, but I was forced to take part of it down because I made a game that was out there already. I'm making android videos next and it will be a very long tutorial

  27. Karim Ihab Avatar

    Thanks So much for the Video, and you really can make videos on any topics.
    Did u consider iOS & Objective -C videos
    I've started learning and you are the first that come to my mind.but I couldn't find any videos for you regarding iOS programming.

  28. Derek Banas Avatar

    I did that already 🙂 Look at Java Video Tutorial 44, 45 and 46

    If I had more time to make videos, I think I could cover any subject. I've spent my whole life learning new topics so it is fun for me. Maybe some day I'll be able to turn this hobby into a job

  29. Таня Чувакова Avatar

    You really can do any tutorial?! Maybe you can make tutorial about working with xml in java? :3

  30. Derek Banas Avatar

    Спасибо. Я очень рада, что вам понравилось 🙂

  31. Таня Чувакова Avatar

    Derek, ты супер!!! Твои видео просто невероятно полезны!!!

  32. Derek Banas Avatar

    Thank you very much 🙂 There are ways to download the videos and a quick search will provide the answer

  33. Herp Derpingson Avatar

    No matter what type of file you are trying to save, you basically have to put all the information into a string and write it into a hard drive.
    Say in minecraft probably the block id and location is saved and then the entire thing is compressed and encrypted. Then the unreadable string is saved with a ".dat" extension

  34. Derek Banas Avatar

    I'm sorry, but I can't do that. I had a lot of trouble when I allowed people to download them. I had a guy selling my videos. If you look into it, you can still find a way to download them. Why not watch them on YouTube for free? I almost never even use preroll ads

  35. Jeremie Boudreau Avatar

    I am just all the tutorials quickly cause I am curious, but I think you should of done your java tutorials with this style, like the presentation thing at the begening

  36. Derek Banas Avatar

    I don't know about subclassing another JComponent. I think I'd just paint everything from scratch. That way you can make it look however you want. If you use JComponents to much they will look completely different on every machine. I'm planning on covering Java 2D maybe depending on how voting goes next week.

  37. TheDivergable Avatar

    im understanding all that and also there is going to be key navigation. But my main question is that thing i told you possible? If yes, how?

  38. Derek Banas Avatar

    This sounds like something that would just be handled by painting what looks like components in a paint window. Then you'll have to simulate button clicking or whatever by capturing where the user clicks. You'll have to throw your own exceptions for those mouse clicks to react to the user

  39. TheDivergable Avatar

    Continuation of the last Comments…

    FYI I'm not talking bout the default java dialogs. I'm talking bout me drawing my own dialogs.

Leave a Reply

Your email address will not be published. Required fields are marked *