Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: [gef-dev] Performance suggestion 1 - Arrays

gef
Discussion topic

Back to topic list

Re: [gef-dev] Performance suggestion 1 - Arrays

Reply

Author Bob Tarling <bob dot tarling at ntlworld dot com>
Full name Bob Tarling <bob dot tarling at ntlworld dot com>
Date 2004-01-11 15:30:26 PST
Message Message>Iterators are only bad when they're the only way to iterate. Usually
you can also iterate by asking for the size and using indexed access, i.e.
getChildCount() and >getChild(int). Adding getChildIterator will make some
kinds of iterations easier, since the iterator can be passed to and returned
from methods (the main >advantage of encapsulating state in an object).
The standard Iterators returned from Collections are not that good at
encapsulation. They contain a remove method which could be used to remove a
child fig without GEF being aware. So I would either have to create my own
specialist Iterator that throw an exception on remove or return a copy of
the collection to be sure of encapsulation. At the moment GEF is moving
towards returning copies of collections.

I don't like the idea of throwing an exception on remove. I'd rather be
typesafe at compile time rather than throw an exception on what is not
obvious misuse.

I'm drifting towards the idea of absolute encapsulation by just having
getFig(int), getFigCount(), getFigPosition(Fig), addFig(Fig), removeFig(Fig)
methods and not returning any arrays or collections.

However I think that so many people are used to dealing with arrays and
Collections and would prefer a smaller API to give them such known objects.

Also that so many other API's take arrays or Collections as arguments that
they may be more convenient objects to pass to other systems.

So I'm not yet agreeing or disagreeing with you I'm still wavering.

Maybe I can do both but the JavaDoc must make the user aware that "Fig[]
getFigs()" returns a copy not not actual instance. So if they want absolute
performance they should use the other access methods.

Bob.


--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: dev-unsubscribe at gef dot tigris dot org
For additional commands, e-mail: dev-help at gef dot tigris dot org

« Previous message in topic | 5 of 7 | Next message in topic »

Messages

Show all messages in topic

[gef-dev] Performance suggestion 1 - Arrays Bob Tarling <bob dot tarling at ntlworld dot com> Bob Tarling <bob dot tarling at ntlworld dot com> 2004-01-11 11:08:30 PST
     RE: [gef-dev] Performance suggestion 1 - Arrays hallvard Hallvard Trætteberg 2004-01-11 11:26:50 PST
         Re: [gef-dev] Performance suggestion 1 - Arrays Bob Tarling <bob dot tarling at ntlworld dot com> Bob Tarling <bob dot tarling at ntlworld dot com> 2004-01-11 11:44:38 PST
             RE: [gef-dev] Performance suggestion 1 - Arrays hallvard Hallvard Trætteberg 2004-01-11 12:24:15 PST
                 Re: [gef-dev] Performance suggestion 1 - Arrays Bob Tarling <bob dot tarling at ntlworld dot com> Bob Tarling <bob dot tarling at ntlworld dot com> 2004-01-11 15:30:26 PST
                     RE: [gef-dev] Performance suggestion 1 - Arrays ipreuss Ilja Preuß 2004-01-14 04:59:23 PST
                         Re: RE: [gef-dev] Performance suggestion 1 - Arrays bob dot tarling at ntlworld dot com bob dot tarling at ntlworld dot com 2004-01-14 05:33:35 PST
Messages per page: