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.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Pattern Tools

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have a good example explaining Memento pattern?
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Victor Htet
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Surya.
 
Author
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

Enjoy!
Linda

------------------
Linda Rising
Author of The Pattern Almanac 2000
 
A wop bop a lu bop a womp bam boom! Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!