It may be useful to compare and contrast with XOM?<br><br><a href="http://xom.nu/designprinciples.xhtml#d0e389">http://xom.nu/designprinciples.xhtml#d0e389</a><br><br><div class="gmail_quote">On Mon, Jan 23, 2012 at 9:04 AM, Rolf Lear wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Heh... you are right.<br>
<br>
Element should not be List<Content>, and the getContent() method can<br>
create a dynamic implementation as needed. That's the solution... Element<br>
already has rules about synchronization so multiple 'active' dynamic<br>
instances should not be a problem....<br>
<br>
Thanks. I will play with that concept.<br>
<span class="HOEnZb"><font color="#888888"><br>
Rolf<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Mon, 23 Jan 2012 16:59:35 +0000, Michael Kay <<a href="mailto:mike@saxonica.com">mike@saxonica.com</a>> wrote:<br>
> On 23/01/2012 16:28, Rolf Lear wrote:<br>
>> Hi all.<br>
>><br>
>> I have started on this memory optimization, and it is still in early<br>
>> stages. There is one API issue though:<br>
>><br>
>> The Element API has the two methods:<br>
>><br>
>> addContent(Content node)<br>
>> addContent(Collection<? extends Content>  newContent)<br>
>><br>
>> if I make Element implement List<Content>  (which is what this<br>
>> memory-change will do), then the above two methods become ambiguous<br>
>> because<br>
>> Element will be both Content and List<Content><br>
> And that suggests to me that it is a bad idea.<br>
><br>
> The class hierarchy should reflect "is-a" relationships, it shouldn't be<br>
<br>
> designed to tweak performance. It's not true that an Element and its<br>
> contents are the same thing, therefore it's wrong to treat them as being<br>
<br>
> the same object. It will only lead to confusion.<br>
><br>
> You can achieve the memory saving by having Element.getChildren() create<br>
<br>
> the returned List object dynamically (it doesn't need to copy any data<br>
> to achieve this).<br>
><br>
>  > The logical thing to do would be to deprecate addContent(Collection)<br>
><br>
> I don't think that solves the problem. There will be cases where<br>
> existing code fixes up to the wrong method, and ends up adding the<br>
> children of an element to a new parent rather than adding the element<br>
> itself.<br>
><br>
> Michael Kay<br>
> Saxonica<br>
_______________________________________________<br>
To control your jdom-interest membership:<br>
<a href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com" target="_blank">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a><br>
</div></div></blockquote></div><br>