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
1
vote
2 answers

WPF : Disable Undo in an editable ComboBox

I have implemented an undo system based on the Memento pattern. I disable the built in Undo on TextBox and was wondering how to do this on a ComboBox. The Combobox I have is editable, so it contains a TextBox, how do I access this to disable the…
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
1
vote
0 answers

Memento or Command Pattern?

I have a JavaScript web app (Backbone for my models, ReactJS for my views) which has two 'display modes', which the user can toggle between, using a button. These modes render data from my model - which is a tree structure, implementing the…
ChrisM
  • 2,128
  • 1
  • 23
  • 41
1
vote
2 answers

How to implement Memento Pattern in Kotlin

I am currently trying to implement some design patterns in Kotlin as an exercise and I'm a bit stuck with the 'Memento' pattern. My reference resource is SourceMaking: Memento. I want to implement this structure: While following their…
Daniel W.
  • 623
  • 6
  • 14
1
vote
2 answers

Why use Memento pattern while it can be done even easier?

Why saying that Memento is doing its job without violates the encapsulation, while I can implement the simple way but also without violate the encapsulation? What is the use of Memento? I have a sample program, which will save the student details…
Newbie
  • 1,584
  • 9
  • 33
  • 72
1
vote
2 answers

Undo/redo memento pattern c#

I am trying to implement the Undo/Redo functionality for the nodes of a tree in C# (treeView component). I have used the memento pattern but I am having trouble with the Redo part. I cannot see where my logic is flawed. Here are some snaps of the…
MonicaS
  • 155
  • 1
  • 3
  • 18
1
vote
3 answers

Self-contained generic memento

Dearest fellow programmers, I seem to lack some understanding as of how the referencing works in C#. The case: I tried to implement some sort of Memento proxy which would wrap an interface and store every parameter that we're provided to the method…
user2211559
1
vote
1 answer

What is the need for Memento Design Pattern in Calculator undo scenario

I am reading about Memento design pattern. I came across an example which talks about Calculator undo functionality. I am able to achieve the Calculator Undo with the below code: Calculator public class Calculator implements Cloneable { int…
Sowmiya
  • 313
  • 2
  • 12
1
vote
1 answer

Usage of Memento in pseudorandom number generator

I would like to ask, how exactly is used memento in pseudorandom number generator? I have high level knowledge of pseudorandom number generator but I don't see there any memento (even I read it's there). Thank you for your answer so much :)
David Gregor
  • 1,855
  • 1
  • 13
  • 14
1
vote
2 answers

Comparing two object state,before and after update

first things first. I have the following classes: class Employee { private int employeeID; private string firstName; private string lastName; private bool eligibleOT; private int positionID; private string positionName; …
reggie
  • 857
  • 4
  • 15
  • 24
1
vote
1 answer

Why does a Memento object have a setState() function?

This is the one thing I don't understand about this pattern. Why doesn't a Memento object just have a constructor and getState() method? When does it make sense to set the Memento's state after creating it? Isn't that like changing the past?
Outback
  • 542
  • 2
  • 8
  • 20
1
vote
3 answers

Undo/Redo Implementation For Multiple Variables

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; …
Shaun Hamman
  • 2,287
  • 4
  • 21
  • 33
1
vote
2 answers

Proxy & Memento Patterns

Proxy - what code (and where) translates ProxyService into RealService calls? Why/when use this? Layers - how to implement? Memento - why not just persist state to a cache or file? My understanding of the Proxy pattern is that you have some kind of…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
1
vote
2 answers

Jquery Forms: using the memento pattern to build a dirty form notification system - exisitng patterns?

I am currently building a script which will notify the user that the form has been changed before they navigate away from the page (This is an ASP.NET MVC app btw). I first started out building a simple script which detects if the user changes any…
Shawn J. Molloy
  • 2,457
  • 5
  • 41
  • 59
0
votes
0 answers

Performance of Memento vs. in-memory database options

As part of my VS code extension, I have a localdb I'd like to write and query values from. I know there are many in-memory db options for JS/TS (lmdb, pouchdb, etc.). Are there any performance comparisons for VS code's own local storage options…
0
votes
0 answers

memento pattern - encapsulation and reusability of memento object

class Originator { private String state; Originator(String state) { this.state = state; } public void setState(String newState) { this.state = newState; } public Memento createMemento() { return new…