Hey, do you know

I think many developers for receiving value from field usually wrote next code:…

dim n as integer

n = doc.fldName(0)

but they have to know that this code has some weak sides:

  • it slowly then doc.GetItemValue(“fldName”)(0) near 15-20%;

  • if in new version of Lotus Notes will appear new method with name “fldName” the application will work wrong

It’s just FYI

Thnx :slight_smile:

Subject: Hey, do you know…

While I do promote the use of GetItemValue() as much as Willy Lorenzo demotes it, the numbers you give are way over the top. Back in Notes 4.x, the difference between extended class notation and the use of methods to get and set field values was reported to be around 10%, not more. Since then, the difference - if at all - has decreased, not increased.

And for every serious piece of code, that does anything more but just retrieving 1000 field values, the difference will be insignificant. Taking care of not using really expensive functions like GetView() or even ComputeWithForm() if not necessary, avoiding nested loops where they can be avoided and using ColumnValues instead of GetItemValue when possible will gain a lot more.

As I said, I prefer the use of GetItemValue(). The second point is a valid, but looking at your field names you can probably tell pretty reliable, how likely the addition of such a method would be. Some advantages of GetItemValue are: You can compute the field name at runtime, it works with special characters like $ without the need to add a leading ~ and it looks more consistent over all.

Subject: RE: Hey, do you know…

I agree on all of this analysis.

I’d also add that, on the other side, the use of the extanded class sometimes makes development a lot faster and makes for a more readable code, especially when you must assign a lot of values from doc A to doc B, especially when some of these fields may contain multiple values:

docA.field1 = docB.field1

docA.field2 = docB.field2

docA.fieldN = docB.fieldN

is a lot faster and easier to read than the GetItemValue counterpart.

Subject: RE: Hey, do you know…

Taken apart personal preferences, you’re probably right. But in such a case, using CopyAllItems() and then removing only the unnecessary ones might be both, even shorter to write and faster to run.

Edit: Your posting made sense even without your latest edit. :slight_smile:

Subject: RE: Hey, do you know…

Humm… I am not sure about this… I encountered this situation quite a few times, and after some experimentation, I realized that the copyAllItems method often introduces annoying side effects, because it will copy also $internalFields, signatures, and so on.

So removing these internal fields can sometimes be a lot of trouble, as opposed to copying only the wanted fields into a fresh, clean document.

But yeah, at this point it’s a case by case basis :slight_smile: