Talk:Memento pattern

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computer science (Rated Start-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 
WikiProject Java (Rated Start-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Java, a collaborative effort to improve the coverage of Java on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 

comment[edit]


The Java example is correct, the C# example is flawed. The C# example got to go. My personal opinion is that a stack is often a better solution than memento.


Man, the CareTaker can save more mementos, not only of 1 object, and can save a lot of them. —Preceding unsigned comment added by 24.232.232.20 (talk) 15:16, 15 August 2008 (UTC)


I would like to request more information on the role of the CareTaker. From the explanation and the samples, it is not clear as to what the purpose of the CareTaker is. Specifically, why would you store the Memento in the CareTaker and not in the code that contains the instance of the Originator. The CareTaker appears to serve no purpose other than to complicate the design. 64.201.213.84 (talk) 01:50, 21 March 2008 (UTC)


I would use Vector instead of ArrayList in CareTaker, because ArrayList does not take care of sorting. 193.159.228.66 15:06, 11 January 2007 (UTC)

"The caretaker first asks the originator for a memento object."

This is not in accordance with the given code. There the caretaker is passive. It's the controller (main()) that asks the originator for a memento object and hands it over to the caretaker which only acts as a storage. Md2perpe 20:03, 20 September 2006 (UTC)

Yes. The code is ridiculous. The "As3Memento" should just be CareTaker. It would be simpler, and would fit the description of the pattern. 82.230.65.68 (talk) 20:33, 29 January 2009 (UTC)


I think it is ridiculous to post the same (long) code example in two, basically identical languages as C# and Java. One of them should be removed. I don't give preference to any of them, so I'm removing the longer one. --Zigmar 14:33, 31 October 2006 (UTC)


Now the examples are in ActionScript 3, Java, and Ruby. At least one of these should be removed; ideally, only one would be kept, and in the most commonly used language of the three. Dhasenan (talk) 19:18, 21 May 2009 (UTC)


Is every trivial thing now a design pattern? Encapsulating the state of an object into a different object is pretty redundant because an object is defined as its own state plus methods (which are the class’ properties).—☠☢☣[d] 00:02, 6 August 2013 (UTC)

Pseudorandom[edit]

Classic examples of the memento pattern include the seed of a pseudorandom number generator [...] Someone please clarify how the memento pattern is used in this case. Thanks, --Abdull (talk) 21:34, 27 October 2008 (UTC)

question on style[edit]

The memento is marked as public static nested inner class. Its enclosing class is package scoped. Do you think that should be improved? Kind regards.