HA! I guess I've been using joda-time for too long... I've always treated Date as immutable, too bad Java 6 has to be backward compatible with Java 1.1 or the setter methods could have been removed a LONG time ago!
> but I prefer to give a > short advice instead of a longer one informing the exceptions to the rule. That's a valid point of view, but to say "never" without an explanation leaves me feeling empty inside ;) Josh On Wed, Jul 14, 2010 at 11:22 AM, Thiago H. de Paula Figueiredo <thiag...@gmail.com> wrote: > On Wed, 14 Jul 2010 15:13:06 -0300, Josh Canfield <joshcanfi...@gmail.com> > wrote: > >>>> @Property >>>> private Date addedToJumpstart = new Date("2010-07-14"); >>> >>> Never initialize fields like you've done in the above snippet because of >>> the >>> page pooling. Use the activate or begin render event to initialize >>> fields. >>> >> >> In general that's sound advice, but if you look at the use case here >> he's building a constant (maybe it should actually be a constant?) > >> safe.onstants should be declared as constants (final static). You're right >> about initializing fields with immutable values, but I prefer to give a >> short advice instead of a longer one informing the exceptions to the rule. > >> Also, Date is an immutable object so using it as an initializer is > > It isn't. You need to invoke deprecated methods, but it has many setXXX > methods. > >> The danger with field initializers is that they'll be saved as >> the default value for the field and modifications can be >> unpredictable. > > Absolutely right. :) But this is also a huge security hole: the data store > by one user in this object will be viewed by another user that happens to > have a request handled by the same page object. > >> So, don't use mutable objects to initialize fields >> unless you are really sure about what you are doing. > > Or never. :) > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and > instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- -- http://www.bodylabgym.com - a private, by appointment only, one-on-one health and fitness facility. -- http://www.ectransition.com - Quality Electronic Cigarettes at a reasonable price! -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org