On 7/6/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> i think your argument is willfully slanted. generic manipulation and
> persistence can be good reasons to reach into an implementation which
> otherwise does not wish to expose properties or fields at all. i
personally
> prefer objects that keep all these details private. i would hope that
> private accessor methods took precedence over private fields, but
> given that, i think accessors in general are best avoided and it's not
> necessarily good to expose private details simply to allow them to
> be manipulated by a framework such as spring, wicket or hibernate.
> that said, i think the real root of this problem is that java simply
> fails to adequately express the protection attribute granularity that's
> required here. being able to define new protection attributes that
> limit the visibility of details based on the package (and possibly other
> details like the thread group) of the caller would be the best way and
> at the present time quite impossible.
As much as I agree with you in general, in this particular case, we
provide direct access to private members where you normally (using
straightforward Java/ no introspection) wouldn't have it.
i disagree completely. the most common usecase for this is for components to
access their own private fields via property model.
class namepanel extends formcomponentpanel {
private string first;
private string last;
namepanel(..) {
add(new textfield("first", new propertymodel(this, "first"));
...
}
updatemodel() { getmodel().setobject(first+" "+last); }
}
in the above - first and last are private implementation details of the
panel. i do not want them exposed via public getters/setters. so in order
to avoid it i need to write an inner class that implements imodel for every
field i want to access - no thanks!
Theoretically, this could result in people accessing those members
directly where they shouldn't. Even if you think that's fine, I doubt
whether this is something Wicket should support.
theoretically i can access private fields without wicket as well.
theoretically i can rewrite the bytecode and turn every private field into
public. this is a problem of practicality.
it is a religious issue, but an undisputable fact is that this feature saves
a lot of time and verbousity.
now if you want to get clever you can build in a check to see if the model
is glued to a component whose private fields it is trying to access and try
and restrict it, but honestly i see no reason to go this far and add
overhead
-igor
Eelco
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user