Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Blogs

photo

Yellow is the...

55 Entries |  Tim Tripcony
Updated 
No Ratings 0     Comments 22
photo

TexasSwede

66 Entries |  Karl-Henry Martinsso...
Updated 
No Ratings 0     Comments 59
photo

Lotus Nut

69 Entries |  Chris Whisonant
Updated 
Ratings 4     Comments 96
photo

Urs Meli

19 Entries |  Urs Meli
Updated 
No Ratings 0     Comments 14
photo

Uh Clem's Adm...

35 Entries |  Chris Mobley
Updated 
Ratings 5     Comments 42

Dogear Bookmarks

.Domino Framework

Blog Authors:  Peter Presnell  

All entries tagged with save

Minimising Document Changes

Peter Presnell  |     |  Tags:  save edithistory .dominoframework  |  Comments (0)
I common problem I encounter when maintaining Notes applications is that documents are being saved multiple times as the result of a single event/action.  In some cases there may not have been any changes made to the actual data.  Reducing the number of times a document is  saved can generate a number of benefits to the application.
  1. Application Performance: The save operation is an expensive one. The fewer the number of saves, the faster the code runs.
  2. Server Performance: Each and every time a document is saved it creates the potential need for the server to update every view index to establish if the change has an effect on the view.  The server may also need to update the full text index.  If the data did not change this work results in no change (but the server doesn't know that!)
  3. Reduced Conflicts: A repeated number of saves can result in a save conflict being generated.  It also increases the chances of replication conflicts if the document is being edited on another server.
  4. Accurate Edit History:  The document history is updated each time the document is saved.  The date/time of the last change and the identity of the author is somehwat invalid if the actual data did not change.  The number of entries in the edit history can also become much larger than it needs to be if additional saves have been performed.
One of the main reasons for multiple saves is the difficulty of keeping track of when changes had been made.  e.g. each section of code does a save just in case the next code block doesn't do a save.  One of the way to minimize the number of changes is to keep track of whenever any item in a document has been changed and then only save the document if a change has been made (to one ore more items).  The .Domino Framework provides one potential solution.  Being  Object Oriented, the document-based classes maintain an internal iHasChanged variable that is initially set to false.  Each of the Property Set code blocks sets the iHasChanged variable to True.   The .Domino Framework Property Generator Tool provides the option to include this logic as part of the p[roperty code it generates.

e.g.
Property Get CompanyName As String
  If iDocument Is Nothing Then Exit Property
  If iDocument.HasItem("CompanyName" ) Then CompanyName$ = iDocument.GetItemValue("CompanyName" )(0)
End Property
Property Set CompanyName As String
  If iDocument Is Nothing Then Exit Property
  Call iDocument.ReplaceItemValue("CompanyName",CompanyName$)
  iHasChanged = True
End Property


It is then possible at the very end of a code block (e.g. event or action) to test to see if any changes have been made and only invoke a save when the variable has been set. 
Note: The framework's DominoDocument class has a Save event which supports the above by only saving the document if a change has been made (iHasChanges = true).  It also resets the flag after the save.
To further reduce the number of changes it is also suggested that comparisons be made with the existing value before updating the object's property.

e.g.
If Employee.CompanyName$ <> CompanyName$ Then Employee.CompanyName$ = CompanyName$
If Employee.Postcode$ <> Postcode$ Then Employee.Postcode$ = Postcode$

Using the above it is often possible to develop code that only needs to do a single save at the very end if, and only the values of at least one field have been changed.


Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.