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 be able to shed some light on the ways to implement the pattern? My research has came up with a sort of mixture of all different things and has just made everything confusing.
Thanks
The Java Collections framework defines
Queue, which can help.Candidate code:
Notably missing from this code are many things, but are easily implementable:
Tdoes not implementSerializable;Etc.
Sample code:
In effect: this is a braindead implementation which can be improved, but which can be used as a basis — extending it depends on your needs 😉