Iterators/vectors (was: [Biocorba-l] BSANE and bioCORBA)
Antoine van Gelder
antoine@egenetics.com
01 Jun 2001 10:26:42 +0200
On 31 May 2001 23:39:19 +0100, Martin Senger wrote:
> Although I thing that it is not big issue I feel that implementation
> with 'out' parameter and returning boolean is easier and also it saves one
> network call.
> I do not like raising any Exception as a "normal" behaviour - that
> makes the codeclumsy and less readable.
Iterator patterns that return bool are much cleaner as it allows for
code such as:
Object obj;
while (someIterator.next(&obj)) {
obj.dostuff();
}
Instead of:
while (someIterator.has_more()) {
Object obj = someIterator.theObject();
}
Which is heavier on both network calls and object constructor calls.
Or even worse if I understood Brad correctly:
try {
while (someIterator.hasNext()) {
SomeObj obj = someIterator.the_object();
}
} catch (SomeException) {
// extremely cpu expensive way of ending a loop adding huge
// overhead to even the simplest algorithm not to mention
// the pain you cause in terms of memory management for
// c++ developers.
}
- a