Thanks, Max, I guess I can live with a few helper methods, for example,
in ElementListUtils. Code readability and avoiding trivial coding
mistakes is important, especially in such a complex package as
"layoutmgr".

On 09.06.2008 18:56:52 Max Berger wrote:
> Jeremias,
> 
> actually I had the same reservations (especially about the "last  
> element", and if you have a real problem with this feel free to revert  
> this patch. Maybe we could write a simple helper method instead?
> 
> static Element getLastElement(List l) ?
> 
> Would that disperse your concerns?
> 
> Why I did it: For the exact reason that the interface is more  
> convenient. You are only partially right that LinkedList is the most  
> efficient interface: I was digging through the LayoutCode, and found  
> places where a single element list is created:
> 
> LinkedList l = new LinkedList()
> l.add(element)
> return l.
> 
> In this case, Collections.singletonList() is MUCH more effective.  
> AAMOF, on all list where you know the size beforehand (most cases in  
> the layout, becasue you know that x elemnets are going to result in x  
> layoutElements) arrayList is more effective.
> 
> 
> Background: I discovered that passing back multiple LayoutContexts is  
> not as easy as I thought, and I need to do some refactoring in the  
> layout code to ensure this is possible - therefore this (and the last  
> cleanup). I really need to make the code easier to read before I can  
> change it.
> 
> Max
> 
> 
> Am 09.06.2008 um 16:40 schrieb Jeremias Maerki:
> 
> > Frankly, I'm less than thrilled. I appreciate the good will behind  
> > this
> > but I'd have appreciated some advance warning, too. My concern is  
> > that:
> > -        ListElement last = (ListElement)contentList.getLast();
> >
> > is much easier to read and write than:
> >
> > +        ListElement last = (ListElement) contentList
> > +                .get(contentList.size() - 1);
> >
> > When working with element lists constructs like the above are  
> > everywhere.
> > A linked list IS the most efficient data structure for element  
> > lists. I
> > generally support using the generic type instead of the specific class
> > (i.e. List instead of ArrayList), but LinkedList is adding some often
> > used methods for element lists which improve code readability. I'm
> > curious what other committers think about this.
> >
> > On 09.06.2008 16:25:29 Adrian Cumiskey wrote:
> >> This is really good Max, really appreciate what you are trying to  
> >> do here.  It must have been quite
> >> boring and laborious...  but great cleanup work :).
> >>
> >> [EMAIL PROTECTED] wrote:
> >>> Author: maxberger
> >>> Date: Mon Jun  9 07:15:38 2008
> >>> New Revision: 665699
> >>>
> >>> URL: http://svn.apache.org/viewvc?rev=665699&view=rev
> >>> Log:
> >>> Replaced LinkedList with generic List interface
> >>>
> > <snip/>
> >
> > Jeremias Maerki
> >
> 




Jeremias Maerki

Reply via email to