Buffer Advantages

What are the advantages/disadvantages of creating buffer(s) of database table?
Throughout my application, before doing anything with the db table, develpoer has defined the buffers for db table?

Thanks
 

tamhas

ProgressTalk.com Sponsor
Defining buffers makes it easier to manage scope. E.g.,

procedure blahblah:
define buffer buCustomer for Customer.
...
end procedure.

Means that you know absolutely that buCustomer will be scoped to the procedure whereas, simply referring to Customer here and elsewhere in the program will cause the buffer to be scoped to the whole procedure. Customer is a buffer too, just the default one.
 

tamhas

ProgressTalk.com Sponsor
That *is* the advantage. If you use the default buffer, then every reference in the program will refer to the same default buffer and you won't be able to control scope. E.g., if you say "do for customer" it will fail to compile if there are any references to customer outside that do block that are not themselves within another such do block. By defining buffers, you explicitly scope that buffer to the internal procedure, function, or whatever in which it is defined. No leaks.
 

RealHeavyDude

Well-Known Member
To add to what tamhas said:

The bad, worse, worst thing about not controlling buffer scope is when you're updating the database. If you don't use a defined buffer that is strong scoped to the same block to which the transaction is scoped you may wind up dead ( share ) locking each and everyone. At the end of the transaction scope, if the buffer scope is larger, the lock on the record doesn't get release completely, instead it get's downgraded to a SHARE-LOCK - there you are ...

It's about control: It's up to you to trust that the default behavior will eventually behave like you expect it too, but I would like to take control and responsibility. It's like with the garbage collection in other technologies - it's a nice thing, but I would just use it as a last resort and not rely on that it takes care in the right way where I am sloppy ...


Heavy Regards, RealHeavyDude.
 
Top