« Posts tagged Clone

An easy way to revert changes in Object data

A quite common problem in an MVC GUI is the need to revert changes in the model made by the user. Let’s say you create a UI where the user can modify some fields that are bound to a model object. After the user already did some changes, he recognizes that he entered some wrong data and wants to cancel the editing. So what now? The data is already written into the model.

The easiest way to revert this changes is obviously to let the user work with a copy of the real data object. So let’s add a clone method to the model and mark it as Serializable. »Read More