Re: reduce redundant code
- From: "MP" <NoSpam@xxxxxxxxxx>
- Date: Wed, 12 Mar 2008 12:32:42 -0500
"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> wrote in message
news:ORgyv8FhIHA.5088@xxxxxxxxxxxxxxxxxxxxxxx
snip
"MP" <NoSpam@xxxxxxxxxx> wrote
I have to loop through the whole bag to see if it's A B or C in order to
put
it *into* my collection in the first place.
seems better to just loop once???
The point was to identify code where you are testing for the same
object types (eg: A, B, and C) and load that group into a collection
once at the start of your application, or upon loading a new file,
or whatever the trigger is for the API to create its objects. Once
done you need not re-load the collection again for all those places
that used tests for those types.
Yes, you'd have loop through the bag to build the group collections,
but from then on, type testing would not be used within those loops
that used a grouped collection.
LFS
Ok I see what you were thinking of.
How this works in this case is
For Each File In Folder
For Each Obj In File
'check obj
Next
Next
so the collection(bag) is only accessed once
but, yes if the file were open for some time and various operations
performed on the collections at different points, then yes, I'd save a
collection and reuse it.
Thanks for your insights
Mark
.
- References:
- reduce redundant code
- From: MP
- Re: reduce redundant code
- From: Ralph
- Re: reduce redundant code
- From: MP
- Re: reduce redundant code
- From: Ralph
- Re: reduce redundant code
- From: MP
- Re: reduce redundant code
- From: Larry Serflaten
- Re: reduce redundant code
- From: MP
- Re: reduce redundant code
- From: Larry Serflaten
- reduce redundant code
- Prev by Date: Re: Runtime Error 3343 - Unrecognized Database format
- Next by Date: Re: reduce redundant code
- Previous by thread: Re: reduce redundant code
- Next by thread: Re: reduce redundant code
- Index(es):
Relevant Pages
|