Skip to content
Home ยป Best Practices

Best Practices

More thoughts on Content Assist

Recently I write about best practices for commenting for content assist. I’ve been writing a lot of LotusScript recently (I’m making a present for you), and in trying to make the content assist as helpful as possible, I’ve had some additional thoughts. Use long lines in comments It’s unhelpful that the IDE considers each line a separate paragraph and inserts spacing between, like this: This is where a line break appears in the code, but there the lines are close together and the indentation provides a guide to what should be grouped together. To fix this, I’ve been just writing really long lines in the comments. If I intend something to be a paragraph, I put it all on one line. This does make it a little harder to read in the IDE, but I… Read More »More thoughts on Content Assist

Dialog warning of possible solar nova.

Users don’t read your dialogs

You know how you open a dialog to ask for confirmation or additional information, or to warn them what’s about to happen? Yeah. People don’t read that stuff. Here’s what to do about that.

Lazy code

A best practice for coding involves delaying slow operations until certain they’re needed, then caching the result.

NotesStream performance

Lars Berntrop-Bos posted a comment concerning the LotusScript NotesStream class and his practice of reading as large a block as he possibly could to optimize performance. I decided to run a test to see how much difference that made. The results are as follows: Block size (bytes) Runtime to read a large file (seconds) 512 10.30 1024 5.09 2048 2.75 4096 1.49 8192 0.86 16384 0.52 32768 0.35 65536 0.26 Each of these cases is doing the same amount of work — reading every byte in the same large binary file. The effect of increasing the block size is dramatic — the largest possible block size was 40 times faster than a 512-byte block. 216 bytes is the upper limit of the NotesStream.Read method, because that’s the maximum number of elements in the array datatype… Read More »NotesStream performance

By Value, By Reference

This is about how function and subroutine parameters are passed in LotusScript, and how to use that intentionally in consideration of code maintainability and performance. For basic types There are two ways a caller can pass a parameter to a subroutine or function. A call “by value” gives the subroutine a copy of the value. A call “by reference” gives the subroutine access to the caller’s variable, so it can change the value of that variable. Here’s an example: Sub fie(a%, b%, ByVal c%) a = 11 b = 12 c = 13 End Sub Sub Initialize Dim x%, y%, z% x = 1 y = 2 z = 3 fie x, (y), z Print “x=” & x & “, y=” & y & “, z=” & z End Sub The output of this code… Read More »By Value, By Reference

Can you please translate?

Ok, it’s my blog so I get to vent. Here is a fact: 80% of text fields on Notes forms would be improved with an input translation formula. This is the best formula for most cases: @Trim(@ReplaceSubstring(@ThisValue; @Char(9):@Newline; ” “)) Rarely do we really want to allow tabs, leading or trailing spaces in a text field. Sometimes newlines, but the formula is easily adjusted to allow that. Of the remaining 20% many are identifiers that shouldn’t contain any whitespace. @ReplaceSubstring(@ThisValue; @Char(9):@Newline:” “; “”) I’m working on a tool called The Developer’s Friend that contains, among other things, some database design reports and fixup tools. I think I’ll add one to list the input translations for all fields so you can easily scan down the list and find ones that need something more than the nothing… Read More »Can you please translate?

The forgotten logical operators

Here’s something I notice in a lot of other people’s code I look at, which has always bothered me. This isn’t language-specific — I see it everywhere. Programmers create logical expressions with the boolean operators And, Or, and Not. It seems to require a sort of sideways view of things to apply the additional operators that work with boolean values, Eqv and Xor (or to use their non-bitwise counterparts which more people might recognize offhand, = and != (<> in LotusScript). This neglect often results in inefficient and hard-to-read logical expressions. For instance, suppose the code needs to test the assertion: “Either a and b are both 0, or neither is 0.” I often see such a test written as: If (a = 0 And b = 0) Or (a <> 0 And b <>… Read More »The forgotten logical operators