@DBLookups are powerful and, usually, a fast way to find data within an application. When I first started developing Notes/Domino applications I used lookups everywhere, even if I was getting data from the same document. This is bad for performance.
After a while, I understood that a better way to do this was to do just one lookup, get a summarized value from a document, and then parse out various bits of information to different fields on the form.
To create a summarized string, you usually put some kind of separator between the values in the column formula, or even a hidden field on the form that does the computing of the summarized values -- for even better performance, since the view index will be faster.
For example, a normal string of several values might be: erik~rydberg~sweden~2. You can parse out any value with @left/@right or @word.
There are at least two problems with the above string -- both concern maintaining applications. First, it is hard to figure out what the values are (what does 2 mean in the above example?) Second, it is hard to change the order of the string, remove something that isn't needed anymore or add a value. You can't be sure that nothing is going to break, even if you just add a value at the end of the string – -- especially if you didn't build the application or it was too long ago to remember all the details.
I started to use the following syntax instead:
<firstname>erik</firstname> <lastname>rydberg</lastname> <kids>2</kids>.
I also changed the way I extract values from the string. Now I use @Middle instead. To get the number of kids: @Middle(string;"<kids>";"</kids>").
I think it is safe to say that the string is more readable even for someone who didn't develop the application in the first place. Also, it is a lot easier to change the string since it is not as order-sensitive as the old one was.
This is a very good tip. It's very clear and easy to use, thanks!
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip library by member Erik Rydberg. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.