You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2010/12/19 20:43:01 UTC

[jira] Commented: (WICKET-3273) Redo Componet's internal data and ModelImpl methods

    [ https://issues.apache.org/jira/browse/WICKET-3273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12973039#action_12973039 ] 

Igor Vaynberg commented on WICKET-3273:
---------------------------------------

i dont like this.

a) we do not want component to have generics for model because it is too verbose. something we have tried and rolled back in 1.4 milestones.

b) this increases the memory significantly. two extra slots per component is huge. the data "structure" is there to optimize space, as you have noticed. and it is there for a reason. historically we had separate slots for models, meta, etc, but eventually rolled them in because pages were getting too big.

> Redo Componet's internal data and ModelImpl methods
> ---------------------------------------------------
>
>                 Key: WICKET-3273
>                 URL: https://issues.apache.org/jira/browse/WICKET-3273
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5-M3
>         Environment: all
>            Reporter: Richard Emberson
>            Priority: Minor
>         Attachments: TestRun.java
>
>
> I am in the process of adding type parameters to Component and
> those derived classes are not parameterize so that I can
> get strong typing when accessing a Componet's Model. To do this
> a different mechanism is needed for storing the Model object
> in the Component.
> The current "data" storage mechanism is very well optimized for
> low memory usage. The problem is that one can not use it and still
> have typed Models without casting.
> In addition, the data_* methods are not easy to understand
> nor can their data-structure algorithms be tested without
> exercising other methods (like not being able to test an
> ArrayList directly but having to all access mediated by other
> methods).
> So, for my project I've devised a data structure that allows for
> separate testing and Model strong typing (without having to
> use instanceof and casts). Access to the underlying data is
> also faster.
> I also believe that separating out the data structure is a
> good thing; IMHO, Component is rather plump.
> An attached file contains the IHolder class and implementations.
> Using the IHodler classes, the data instance variable, data_* methods
> and ModelImpl access methods become (this is the
> non-type-parameterized version):
>   // why is this not private in Wicket?
>   private IHolder data = EmptyHolder.instance;
>   private final int data_length() {
>     return data.length();
>   }
>   private final Object data_get(int index) {
>     return data.get(index);
>   }
>   private final Object data_set(int index, Object object) {
>     data.set(index, obj);
>   }
>   private final void data_add(Object object) {
>     data = data.append(obj);
>   }
>   private final void data_insert(int position, Object object) {
>     data = data.insert(position, obj);
>   }
>   private final Object data_remove(int position){
>     data = data.remove(position);
>   }
>   final IModel<?> getModelImpl() {
>     return data.getModel();
>   }
>   final void setModelImpl(IModel<?> model) {
>     data = data.setModel(model);
>   }
> Also, the use of the FLAG_MODEL_SET can be removed throughout
> the rest of Component.
> I actually do not expect the Wicket team to adapt my changes here
> since for Components with data there is an extra reference and
> with Models, yet another reference; which is to say, greater
> memory usage. But, I want strong typing, so this is what I've done.
> Oh, yes, all of the test pass (after adjusting the
> org.apache.wicket.markup.html.debug.WicketComponentTreeTest test).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.