On Jul 24, 2008, at 20:39 , Jeremy Thomerson wrote:

It looks like my earlier message didn't go through. If really your big problem is that you have singleton restraints, where there must be only one instance ever of a particular object, Wicket is NOT the problem. Anytime you have that constraint, there are defensive programming things that you need to consider, even without Wicket. Joshua Bloch describes this well in
Effective Java.  To get around the problem you have, simply override
readResolve and return the unique instance of that class. This can also be done with enums, etc, by overriding the serialization methods to provide custom serialization. And this *should* be done at any time that you think something is going to be serialized and you have unique constraints such as
this.

I know that technique (but thanks for the pointer), I've implemented it for other "unique" objects in a different project, where they _need_ to be serializable, because they are transferred over the network. But in that case the extra work is justified by the network - I mean, you must do that because it's a distributed environment. I find still funny to be forced to do the same in an application which is not distributed in nature. If I'm forced to write extra code, probably some model wrapper is better at this point, and probably it's worth while spend a few time to try finding something that can be extensively reused in the same project for different classes (this is what I referred to "design workaround" in my first mail). But, I repeat, I feel like it would be better if I wouldn't be forced to do that.

BTW, things are more complex than your example: my objects are not "singletons", rather they are similar to "flyweights", they are instantiated in multiple instances, but have an uniqueness constraint - that is, each instance represents a concept (say, with an internal id) and there can't be two instances with the same id.

--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
[EMAIL PROTECTED] - mobile: +39 348.150.6941



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to