Questions tagged [memento]

The Memento pattern allows a caretaker object to roll back the originator object to a previous state, offering undo capability. It is one of the Gang of Four's behavioral design patterns.

This is one of the Gang of Four's behavioral , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

More information is available on Wikipedia.

75 questions
0
votes
0 answers

How to set memento in memento pattern

I need to write a Graph class which performs some sort of operations and gives possibility to save it using memento pattern. I am trying to implement that functionality, but I want to have IGraph interface which cannot return explicit type of…
complikator
  • 235
  • 2
  • 8
0
votes
0 answers

Is there any ready made pattern or library to implement Memento pattern for ones classes instead of reinventing the wheel?

I have classes like this: class MyClass{ int myField1; int myField2; MyMemento* getMemento(){ auto m = new MyMemento(); m->myField1 = myField1; m->myField2 = myField2; } void restore(MyMemento* m){ …
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
0
votes
1 answer

Memento pattern undo/redo texteditor

I tried to apply memento pattern to include undo/redo functions in my tex editor app. Let's say it is simplified version :). So far, I haven't figured out how to save and then restore the exact text input from the keyboard. I mean, I have to link…
0
votes
1 answer

Memento Design Pattern - Real World Examples

Can someone give me some real world examples for Memento Design Pattern. I heard that Cart can be considered as one of the Memento Design Patterns. That kind of examples are preferred. Thanks in advance. :)
0
votes
1 answer

Memento pattern issues in c#

I'm struggling to figure out an issue with the Memento pattern. Although I understand it and I'm able to implement it, I must be missing something because it seems to me that if fails when applied to an object that has List type properties. Consider…
cneves
  • 43
  • 6
0
votes
3 answers

Memento pattern and violation of encapsulation

Across the internet I come across with examples of implementation of memento pattern which I consider are fully incorrect. They can be written in both Java and C#. Here a several of them Incorrect implementation of Memento pattern 1 Incorrect…
vborutenko
  • 4,323
  • 5
  • 28
  • 48
0
votes
1 answer

Change original object when reassigning its copy-reference in java

Let s say I have a Game class: Public class Game{ private Board board; private Stack commandStack; //... //constructor... //... Public void createCommamd() { Command command = new Command(board); …
giulio di zio
  • 171
  • 1
  • 11
0
votes
2 answers

Which among these is the proper implementation of the Memento design pattern?

In GOF Book, it says the structure of the Memento design pattern is like this: But when I searched Wikipedia, it says the structure of the Memento design pattern is like this: Which among the both is the correct implementation?
xun yan
  • 69
  • 5
0
votes
1 answer

Memento Pattern and MVC pattern, originator state will be alway duplicated?

I've start implement the undo&redo via the Memento Pattern, my progress till now are those: from Class Controller, function RGB(...): void Controller::rgb(int exp, double cont, int r, int g, int b){ originator->setValue(exp,…
0
votes
1 answer

Memento not update state with undo in Java

I have a graph that contains vertices and edges and I have an originator class that contains the graph that should be used to insert vertices or get the list of vertices in the graph interface vertex public interface Vertex { public V…
Renata P Souza
  • 255
  • 3
  • 20
0
votes
1 answer

Orc.Memento Global Undo with Multiple Controls

I have a need to implement a memento undo-redo pattern. My application has multiple tabs and in these tabs there are multiple controls which all implement Orc.Memento. The trouble I am having is calling undo with the menu button on MainWindow and in…
juicebyjustin
  • 434
  • 7
  • 16
0
votes
1 answer

I need a design pattern to provide undo functionality to my program

I need a design pattern to provide undo functionality to my program. I've already used Memento, but I need another for my coursework.
Daniel
  • 147
  • 8
0
votes
1 answer

Memento pattern in Java - serialization of inner class

Disclaimer - this is a part of a school semester project. We should be using Memento pattern to save an object state. This object is a model in MVC. So the way I have it now is (simplified): public class Model { // ... public static class…
Martin Melka
  • 7,177
  • 16
  • 79
  • 138
0
votes
1 answer

How to store all the information of view part using IMemento?

I have 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. I have created 3 hashmap. 1) hmTextONLY: its…
S-IT Java
  • 127
  • 1
  • 13
0
votes
1 answer

Generic field changed event

I'm currently trying to make a Logger for hundreds of classes, which listens for 3 property's change, and creates a log message if they do. public class MementoLoggerUtility { private SLOC Loc; private AVAL…