Thank you for reading this question. Please help me to solve this complex issue.
Here is the situation:
Oringator holds a object to execute some method.
Memento pattern needs to backup the complex object state in oringator.How?
Example code:
The problem is , java does pass by value, do not pass by reference. But it is a bit tricky for object passing. If I passed an object into the method, although the method holds a new memeory address of object,the memory address is still pointing to the same object which is passed in. See this example: http://www.javaworld.com/javaqa/2000-05/03-qa-0526-pass.html
If I create the memento and pass the object to the new memento object, the memento object still holds the orignal complex object(which is needed to backup).
So, how to create the memento pattern for backup the complex object which is in command pattern?
Thank you.