This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
Hi From Java Design Patterns: Memento pattern is basically uses to save the internal state of an object so youcan restore it later. Ideally, it should be possible to save and restore this state without making the object itself take care of this task, and without violating encapsulation. This is the purpose of the Memento pattern. You can find the further info regarding the patterns at: www.patterndepot.com Surya
Originally posted by Victor Htet: Does anyone have a good example explaining Memento pattern?
Hi, It's hard to learn patterns. It's hard to remember them when you need to use them. One of the effective techniques that I have discovered in teaching people about patterns is to use a real-world, non-software example. Mike Duell has a wonderful on-line catalog of examples for all the GoF patterns and the POSA1 patterns. You can see them at: http://www.agcs.com/supportv2/techpapers/patterns/papers/tutnotes/index.htm Of course, you can also get a copy of the Pattern Alamac -- maybe win a free one this week! That will have summaries and other information about all the published patterns. To answer your question -- a real-world, non-software example of Memento -- when you must take something apart, for instance, if you need to change the wheels of your car, keep other wheels intact so you can remember how to put the wheel back on. A memento is a "reminder" of how things were.