In the Gang of Four’s “Memento” design pattern, the Memento
class looks like a useless wrapper that doesn’t actually provide any value to me.
What is it for? Is there any reason you can’t just pass around the String
object (in the Wikipedia example)?
The memento class is the one holding the different states you are dealing with in your object – it is what enables the “undo/redo” functionality.
The example you have linked to on Wikipedia is rather simplistic, where the “state” is just a string value. Consider that the state could be a bunch of properties that you may want to restore in “batch” and perhaps have several “undo” points with.
2