What is most important: consistency or ease of use?
Olle

2008/12/15 Peter Stavrinides <p.stavrini...@albourne.com>

> >Why is it prohibited to initialize rowsPerPage in the declaration? An int
> is definitely immutable. It's not even an object...
> True, but then the question arises will it become more confusing and appear
> inconsisant?  Especially for new users still learning Tapestry, they may get
> confused as to why primitives can be initialized but not Objects?
>
>
> ----- Original Message -----
> From: "Olle Hallin" <olle.hal...@gmail.com>
> To: "Tapestry users" <users@tapestry.apache.org>
> Sent: Monday, 15 December, 2008 3:32:00 PM GMT +02:00 Athens, Beirut,
> Bucharest, Istanbul
> Subject: Re: T5: How to initialize page members
>
> You're correct about static final. Didn't think of that .
>
> But still I think there is room for improvement:
>
> Consider this use case that is quite clumsy to implement as it is today:
>
> public class APageThatContainsAGrid {
> @Persist private int rowsPerPage = 10; // forbidden!
> void onAction(int rows) {
> this.rowsPerPage = rows;
> }
> }
>
> and in the template a <t:grid rowsPerPage="rowsPerPage" .../> and a couple
> of action links for modifying rowsPerPage.
>
> Why is it prohibited to initialize rowsPerPage in the declaration? An int
> is definitely immutable. It's not even an object...
>
> Olle
>
>
> 2008/12/15 Thiago H. de Paula Figueiredo < thiag...@gmail.com >
>
>
> Em Mon, 15 Dec 2008 06:47:18 -0300, Olle Hallin < olle.hal...@gmail.com >
> escreveu:
>
>
>
> Hi,
>
>
> Hi!
>
>
>
> Beginning with 5.0.17 is is forbidden to have initial values on page
> members, in order to prohibit state leakage between sessions.
> This is fine, since it prevents bugs that can be very tricky to isolate.
>
> You're right.
>
>
>
>
> This contradicts to the Tapestry principle *the simplest choice should be
> the correct choice.*
>
> I don't think so. You have to remember that Tapestry polls page instances,
> so, after one request, Tapestry must restart the page fields values. And
> that the value of a non-primitive field is a reference to an object, not an
> object itself.
>
>
>
>
> IMHO it should be ok to initialize the member in the declaration if it can
> be guaranteed that the value is immutable.
>
> IMHO, the best way to declare a field that is immutable is to make it final
> and static (i.e. constant) for it, not a private field. ;)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>
>
>
> --
> Olle Hallin
> Senior Java Developer and Architect
> olle.hal...@crisp.se
> www.crisp.se
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Olle Hallin
Senior Java Developer and Architect
olle.hal...@crisp.se
www.crisp.se

Reply via email to