PermaLinkLotusScript Variable Name Conventions
07:12:00 AM

In a comment thread over at CodeStore, Ben brings up variable naming conventions in LotusScript. I posted a tongue in cheek response to what I think was a tongue in cheek remark, but it was really only partly light-hearted. I realize that discussions of coding style are about as close to a religious discussion as we can come in technology geek circles, but I'm not one to shy away from such things :-)

I actually do use single letter variable names frequently in script, and I'm not ashamed of it. I am very specific about how I use them. Much of my code starts out as follows:

Dim s as new NotesSession
Dim db as NotesDatabase
Dim v as NotesView
Dim c as NotesDocumentCollection
Dim doc as NotesDocument

When two of the same type of object are required, I do use longer names (and not just db1, db2, v1, v2, c1, c2, doc1 and doc2. I will tend toward things like thisDb and lookupDb, for example, or sourceDoc and targetDoc. Still very generic, but longer in order to define a clear difference. It's more portable to keep the variable names generic. If variable names are things like "projectDB", "peopleView", "taskCollection", etc., then when you want to grab a useful function from one application and re-use it in another you have to change all the variable names to keep the code from looking totally out of place in an application that has nothing to do with projects, people, and tasks. Most functions that I code are small, and many use just a single database, view, collection and document. If the names are going to be generic, as far as I'm concerned they might as well be standardized across as many functions as possible, and they might as well be as short as possible.

The only other places, however, where I will use one-letter variable names are in small loops. (I loosely define a "small loop" as one that fits entirely within one screen in Domino Designer on my development machine. ) I use i, j, and k as the loop control variables for for loops, and n as a single counter or running total within a while loop. I use longer and more specific names, however, for any counters being maintained within the body of a for loop, or for all counters if there is more than one being tracked within a while loop or within the bodies of any set of nested loops. I admit that I am often tempted, but I do avoid using the letter "l" for storing string lengths, because it's too easy to confuse for a numeral "1".

This page has been accessed 637 times. .
Comments :v

1. Wild Bill02/10/2005 08:10:49 PM

Welll.. Its not a *great* system, but if used consistently, then shouldnt be too much of a problem.

Why arent I concerned about naming conventions in Lotusscript ? There are far too many variable/class types around - more than a screenful in v6. Just keeping a list of these taped to your cube-farm cell wall isnt good enough.

What mitigates lack of variable naming standards is keeping the code sequences short and meaningful. Like less than a screenful if you can. So use OO or structural techniques (thats "functions" for you folks at the back of the class... Boom boom!) to break down long sequences. ..

(Code Complete v2 - Microsoft press. Well recommended)

(Also. Code as if you have to maintain this code for the rest of your life. With a hangover. On a monday morning. Whilst stressed. Remember. Make life easy for whoever has to follow - as its most probably going to be yourself...)

---* Bill

2. David Bailey02/10/2005 09:26:33 PM

I use almost exactly the same conventions. Sometimes ordinary minds (mine) think like great minds.

3. Christopher Byrne02/11/2005 03:33:24 PM

I do a slight variation, but never use "s" and I also try to make the view declarations reflect what the view is for easier reading. For example

Dim session as New NotesSession
Dim dbCurrent as NotesDatabase
Dim dbNames as NotesDatabase
Dim viewCurrent as NotesView
Dim viewNames as Notes View
Dim col as NotesDocumentCollection
Dim vCol as NotesViewEntryCollection

and the variable type is always first.

The issue you raise about code resuse is not an issue if naming conventions are set and used across the enterprise. From a controls standpoint (you had to know this was coming ), it helps documentation and facilitates communication between team members.

4. Nando11/13/2005 07:50:43 AM

Think about ROI for your employer and yourself.

I'm Using 'Full' descriptive names for variables
Prefixing them with abbreviation of the object: hungarian notation: str, int, vw, ses, doc
Prefixing them with scope prefix: g for global, m for module, p for paramter

I'm structering my Lotusscript code by OO design, which here is not such
I'm using short fucntions..

This all adds to more readable, maitainable code for me, colleques and hired hands.

I know it takes a little more time to code but tt shortens the time to add, change and debug the code.
So it saves time and your employer money. This not longterm return of investment but in the shortterm.

Wouldn't it be great to be appreciated by the people who use/maintain your code.
Even when you left the company yout follow-up says your done a good job and made his work a lot easier'.
Remember you might meet your manager, follow up, colleques applying for a job at another employer.

I'm not that great mind but i'm using it to its full extend.:

5. vesoftware11/05/2013 10:21:11 PM

Agen Bola Promo 100% SBOBET IBCBET Casino Poker Tangkas Online
ITUPOKER.COM AGEN POKER ONLINE INDONESIA TERPERCAYA : Toko belanja online murah, Promo heboh jual barang hanya Rp 1,-

6. 20161125caihuali11/25/2016 12:13:45 AM

7. chenyingying12/01/2016 09:09:28 PM

8. dongdong806/28/2017 11:38:04 PM Ban.html Air Max.html

9. chenlina07/16/2017 10:25:42 PM
Homepage: http://

10. liuchunkai08/11/2017 03:48:08 AM


11. chenlixiang08/11/2017 08:56:35 AM lauren.html

12. ylq jake08/17/2017 04:50:49 AM,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

13. 20170824yuanyuan08/24/2017 02:35:58 AM
Homepage: http://

Enter Comments^

Email addresses provided are not made available on this site.

You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links

:-x :cry: :laugh: :-( :cool: :huh: :-) :angry: :-D ;-) :-p :grin: :rolleyes: :-\ :emb: :lips: :-o
bold italic underline Strikethrough

Remember me    

Monthly Archive
Responses Elsewhere

About The Schwartz


All opinions expressed here are my own, and do not represent positions of my employer.