memento

Difference between Memento Pattern and Serialization

我是研究僧i 提交于 2020-01-10 08:55:38
问题 I am doing some research into the Memento Pattern and I am generally new to behavioural patterns and with my research I have been getting pretty confused. One of the main things I have been getting confused on is the differences between the Memento Pattern and Serialization. From what I can gather both can be used to store objects and have them brought back at a later date but I have not been able to find a clear cut answer on what the key differences between them are, maybe I have missed

Difference between Memento Pattern and Serialization

廉价感情. 提交于 2020-01-10 08:54:32
问题 I am doing some research into the Memento Pattern and I am generally new to behavioural patterns and with my research I have been getting pretty confused. One of the main things I have been getting confused on is the differences between the Memento Pattern and Serialization. From what I can gather both can be used to store objects and have them brought back at a later date but I have not been able to find a clear cut answer on what the key differences between them are, maybe I have missed

Eclipse call ViewPart saveState on View close

守給你的承諾、 提交于 2019-12-12 11:37:53
问题 I have a Eclipse plugin that uses a view which extends ViewPart . ViewPart has a saveState method which requires an IMemento . I added my code to saveState and the corresponding init method and it works. Unfortunately, saveState is only called if the entire workspace is shutting down. My view is not of such great importance that I can expect it to be opened the entire time. Hence, it would be cool if saveState would be called on view closure. I found a view-part listener as mean to react on

Different ways to implement the Memento Pattern in Java

南楼画角 提交于 2019-12-12 09:56:44
问题 I am doing some research into the Memento Pattern and it seems that most of the examples I have come across seem to be relatively similar (Saving a String into an array and restoring it when needed) now correct me if I am wrong but I believe the method that i just described is "Object Cloning" but what are the other ways of implementing the Memento Pattern? From what I have also picked up on Serialization can be used but there seems to be a grey area with people saying that it violates the

Undo/Redo Implementation For Multiple Variables

不想你离开。 提交于 2019-12-08 04:43:02
问题 I'm trying to refactor an undo/redo implementation I have but am unsure how to go about it. public class MyObject { public int A; public int B; public int C; } public abstract class UndoRedoAction { protected MyObject myobj; protected int oldValue; protected int newValue; public abstract void Undo(); public abstract void Redo(); } public class UndoRedoActionA : UndoRedoAction { UndoRedoActionA(MyObject obj, int new) { myobj = obj; oldValue = myobj.A; newValue = new; myobj.A = newValue; }

Different ways to implement the Memento Pattern in Java

笑着哭i 提交于 2019-12-05 20:53:43
I am doing some research into the Memento Pattern and it seems that most of the examples I have come across seem to be relatively similar (Saving a String into an array and restoring it when needed) now correct me if I am wrong but I believe the method that i just described is "Object Cloning" but what are the other ways of implementing the Memento Pattern? From what I have also picked up on Serialization can be used but there seems to be a grey area with people saying that it violates the encapsulation of the object and isn't a way to implement to Memento Pattern due to this. So will anybody

Java - Memento pattern and Undo

痞子三分冷 提交于 2019-12-03 21:54:59
问题 I am implementing an undo/redo function which requires me to use memento pattern. The flow of the partial program : "...the program then store the previous Vector using Memento Pattern, then the newly created object will be added to the Vector. After that, user may choose a show command to show what is inside the Vector, he can also enter undo command to restore, the undo can be repeated until it is restored to the original state..." From my research, I know there will be an originator,

How is the Memento Pattern implemented in C#4?

久未见 提交于 2019-11-28 07:34:51
The Memento Pattern itself seems pretty straight forward. I'm considering implementing the same as the wikipedia example, but before I do are there any language features of C# that make it easier to implement or use? One obvious feature would be generics, implementing an generic memento will allow you to use it for any object you want. Many examples that you will see will use a string (including all those currently among the replies to this question) as state which is a problem since it's one of the few types in .NET which are immutable . When dealing with mutable objects (like any reference

How to implement good and efficient undo/redo functionality for a TextBox

删除回忆录丶 提交于 2019-11-28 04:32:13
I have a TextBox which I would like to implement undo/redo functionality for. I have read that it might have some slight undo functionality already, but that it is buggy? Anyways, I would like to implement both undo and redo functionality also just to learn how you would go ahead and do that. I have read about the Memento Pattern and looked some on a Generic Undo/Redo example on CodeProject. And the pattern kiiind of makes sense. I just can't seem to wrap my head around how to implement it. And how to do it effeciently for the contents of a TextBox . Of course I could just store textbox.Text

How is the Memento Pattern implemented in C#4?

感情迁移 提交于 2019-11-27 01:37:08
问题 The Memento Pattern itself seems pretty straight forward. I'm considering implementing the same as the wikipedia example, but before I do are there any language features of C# that make it easier to implement or use? 回答1: One obvious feature would be generics, implementing an generic memento will allow you to use it for any object you want. Many examples that you will see will use a string (including all those currently among the replies to this question) as state which is a problem since it