aspose file tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Undo, Memento for Composite Object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "Undo, Memento for Composite Object" Watch "Undo, Memento for Composite Object" New topic
Author

Undo, Memento for Composite Object

marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 152

Hi

I have a mutatable class similar to below, note code abridged to illustrate key points. The key point being that the Element and Variable objects in the maps are mutated outside of the Rendition object (via a web html inteface). That is, the composed state of the Rendition object is not handled by methods in the Rendition object.

I now want to implement an undo facility where any changes to the composed state can be reverted through a call to the Rendition.

To achieve this, I understand that I need to do a major refactor to ensure that all changes of state to the composed Rendition object are handled by Rendition which can then generate a memento object for each change.

Before I undertake this refactor, is anybody able to give me further pointers on moving forward?

Thanks

Marten



when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

You may use "Observer" pattern to cascade your changes.


S.D. MADHAN
Not many get the right opportunity !
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You could also look at the Command pattern. This pattern is very suitable for implementing undo-functionality.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
 
subject: Undo, Memento for Composite Object
 
Threads others viewed
Key in the HashMap.
Using java.lang.Arraylist object in WSAD WebServices
About Undo!
IBM 286 - patterns
converting a string color to an object color
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture