I have found that the biggest problem Lotus Notes faces often centers around performance. It's uncertain whether this is due to wanting to make Notes perform relational/transactional tasks beyond its capabilities, using techniques that were cutting-edge for version 4.14, building more on a Lotus Domino server than it can handle under load, or being unwilling to open the release notes and Help files use newer, streamlined functions and objects. No matter the reason, there are several ways to improve applications.
- Declare all variables using 'Option Explicit.' Domino Designer is accommodating when you design a script in form events or agents by filling in the blanks of variable declarations. However, the compiler assigns all undeclared variables the data type of variant. As you know, variants are extremely expensive memory-wise. Performance-wise, I've tried not to declare a single variable versus declaring every single thing, and have experienced more than 5x improvements in processing time. I recommend putting in the effort up front.
- Use meaningful variable names. Just because you think you'll remember what "a," "u7" and "flip1" meant on Wednesday, you may not remember these variables two years from now when you (or someone else) has an urgent request to use that code.
- Add a REM section with notes on what you're hoping to achieve in the module This can help you or the person who must maintain your application. If your group is more formalized, this is also helpful for code reviews because it allows reviewers to quickly glean the application's purpose from your comments and provides helpful feedback about other ways to do this.
- Use Errorhandling: This isn't required out of the box; and since your function is so tight and narrow in scope that it won't fail, you may ask why it's needed. Errorhandling is helpful in avoiding help desk calls that require you to explain to a user what "Object variable not set" or "variant not found" means in relation to why their record isn't posting their update. While this is likely an easy fix over the phone, it's even easier to assign it to an error handler (or error-handling library module) that can send you an email or error-log link when a 91 or 4063 error occurs. You also can use the canned Error and ERL (error-line, where it occurs) functions to speed up resolution time.
- Take advantage of the @IsError function when using @Formulas. If you're performing a type of @DBLookup or @DBColumn in a computed field and it doesn't work because data has been moved or deleted, Lotus Notes users can still open their documents. Most users would rather receive a blank field or error text than be locked out a document completely only to see an unknown message.
- Clean up unused code prior to deploying into production. When you have a production-ready solution, it's time to eliminate that large block of code that was originally abandoned for another approach. The client application still copies the code to the desktop, even though it doesn't use a character of the code . This also applies to local replicas. Let's call it "bandwidth courtesy." Additionally, remove all extra print and msgbox lines that were used for debugging and logging during the development phase.
The best way to maintain a good relationship with your Notes Domino administrator is to minimize the number of times you bother them by cluttering up server logs. It's even more critical to clean up commented code for Web applications, such as a View->Source, to avoid revealing too much design information to hackers.
- Use a profile document or construct a maintenance area within your application if you have dropdown menu fields that you want to avoid doing a code change to update the list. You still must perform costly lookup functions with maintenance views, so I recommend using the Profile document to benefit from the speedy functions available to access them in both Formula language and via script.
Both methods consume less processor power than GetDocumentByKey or @DBLookup/@DBColumn. You can provide a view button to an admin-level user in the application to access the profile document or to an administration area dashboard that lets high-level users update assorted menu choices. Don't forget to include some validation in the save event so users don't enter something that will disrupt the field or value you referenced in the destination object.
Note: Sometimes requirements force you to base your View selection formulas on date/time functions. However, this can kill performance time in the client and over the Web.
Take, for example, a table structure that divides items from last quarter, two quarters ago, etc., which roll over each quarter. Do you use embedded views with "Select" to grab @Today and hash things out from there? You can, but this will clutter admin logs too much.
Use a scheduled agent to reset view selection formulas involving time functions instead. If you set up a scheduled agent to run at specific intervals, such as monthly, you can use the NotesView object to reset the Selection formula to specific dates. For instance, instead of backing into the current quarter with the function, the script will update the selection formula to > 4/01/2008 & <= 6/30/2008.
LotusScript can work out the date logic in the middle of the night in a few seconds on the first day of the new quarter/month/year. Your generically labeled embedded view will be current for the new period at a substantial performance savings for the Lotus Notes client, Lotus Domino server and the user.
Tutorial: Lotus Notes Domino application development best practices
Part 1: Improving Lotus Notes Domino application performance
Part 2: Tweaking the Lotus Notes Domino application interface
Part 3: Expanding or modifying a Lotus Notes Domino application
|ABOUT THE AUTHOR:|
| Paul Stockinger
Paul Stockinger is currently certified as an IBM Advanced Developer for Lotus Notes/Domino 6 and 7 and has designed Notes and Domino applications since 1997. He can be reached at firstname.lastname@example.org.