Iterators/vectors (was: [Biocorba-l] BSANE and bioCORBA)
Juha Muilu
muilu@ebi.ac.uk
Fri, 01 Jun 2001 13:06:55 +0100
Michael Dickson wrote:
>
> I'll add my "vote" for the original patterns. We discussed precisely
> the issues Antoine raised during the initial discussion which is why we
> settled on the patterns we did.
>
> If I had to change anything about it (and we don't :) I'd replace the
> typesafe iterators with one generic one. Its a small point but the
> other methods generates lots of stubs and skeletons (for languages that
> have them). I generally prefer type safety but in practice this proved
> to be a bit of a pain. So the code you'd likely see would look like:
I agree with you. We have found current type safe iterators bit pain as
well.
>
> Object obj;
> while (someIterator.next(&obj)) {
> TypedObj tobj = TypedObjHelper.narrow(obj);
> tobj.dostuff();
> }
>
> Instead of:
>
> TypedObject obj;
> while (someIterator.next(&tobj)) {
> tobj.dostuff();
> }
>
> I don't feel religious about it but I'd clearly prefer it.
>
> Mike
>
> Juha Muilu wrote:
>
> >Hi Antoine,
> >Nice to have you on the list!
> >
> >So we will keep the iterator/list pattern as used in the BSA.
> >
> >I have found it quite good to implement and use.
> >
> >
> >Antoine van Gelder wrote:
> >
> >>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
> >>
> >>_______________________________________________
> >>Biocorba-l mailing list
> >>Biocorba-l@biocorba.org
> >>http://www.biocorba.org/mailman/listinfo/biocorba-l
> >>
--
+--------------------------------------------------------------------+
|Juha Muilu, Ph.D., EMBL Outstation| Email: muilu@ebi.ac.uk |
|European Bioinformatics Institute | Phone: +44 (0)1223 494 624 |
|Wellcome Trust Genome Campus | Fax: +44 (0)1223 494 468 |
|Hinxton, Cambridge CB10 1SD, UK | http://industry.ebi.ac.uk/~muilu|
+--------------------------------------------------------------------+