Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Memento pattern in swing

 
Vishal Shaw
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Any ideas on how to implement Memento Design Pattern in swing?

Sorry, if I posted in the wrong forum, but I did not find any appropriate forum
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can implement any design pattern using core Java. SInce, you can use core Java in Swing, you can use any design pattern in Swing.

So, you know what's the Memento Design pattern?
 
Vishal Shaw
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayesh A Lalwani wrote:You can implement any design pattern using core Java. SInce, you can use core Java in Swing, you can use any design pattern in Swing.

So, you know what's the Memento Design pattern?


Yes, Jayesh I know about the Memento Design Pattern. It can be used to rollback a state . For e.g. redo/undo an operation.

But I am unsure about it's implementation, like shall I save all the object's state whenever any minute change occurs? How do I save the state, shall I save the object for the same or maintain a log for the changes?
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wikipedia has a good description
 
Vishal Shaw
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayesh A Lalwani wrote:Wikipedia has a good description


I have already studied this page. But there's one problem, in real life scenario, we may do upto 'n' no. of undos and redos. But here , it supports only one. Also, with every object I will have to implement this stuff. So, I was thinking about serializing the states in a log for the same and rollback the states from there.

What do you say? Is it a good idea to save the states in a log and work accordingly?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic