The project that I am currently working on has lot of objects that are serialized in order to get a deep copy of the the existing object. This works fine until we have multiple calls at runtime in some cased we have 100, 200, or even 1000 calls between components and this is where we are hit with performance headache.
Historical reason for copying these objects being cloned is that , two different component working on same objects under different functionality should not change each other e.g. Changes in Swing UI should not change the object values in backend until save or synchronized button is pressed.
We have quite a large code base, I thought if I would write clone based on reflection it will work faster as compared to serialization , but either due to our complex hierarchies of objects or due to some other reason , this approach is even slower.
I also tried using CloneUtils (sourceforge project) , which is slower as well (We are not using Hibernate at all). Spring BeanUtils is not an option (I assume from docs that it only uses beans i.e. introspection and in case I use it if any fields are exposed using non standard accessor , we will not be able to copy those).
Has anyone any idea , improve the performance while still working on different copies. We have an option which will speed up things in case we provide our own copy methods ,instead of serialization, but that has downside of updating these methods every time and if we forget we might loose functionality.
Just give you a hint in how you can improve performance in cases like this: use prototype pattern if you are not already using it.You might gain some perfromance