Old dog, new tricks
Without wishing to sound like an arrogant twonk (but I suppose I will), I found myself somewhat disgruntled recently when I heard I would be required to code a Notes database. “Gah! Not another one!” No-one wants to be a Monkey-Programmer-Boy after all. So, the thing had to be done, and life had to be made interesting. Here’s how I did it:
- OOP. You knew I was going to mention that, didn’t you?
Yes, I decided to do some object oriented stuff with some of the more challenging (and not so challenging) Lotusscript. I’m really glad I did too... a
FormValidatorclass made quick work of the application’s — frankly twisted — validation requirements. - More OOP: I also got around to something I’ve been meaning to write for ages: a
LinkedArrayclass. I’m not too keen on much of the in-built array functionality in Lotusscript (mainly referring to R5 here), so I finally did something about it. The end result is a nifty custom class that allows me to confidently tinker with arrays: check for duplicate elements, add elements, remove elements, insert elements, re-order them, and so on. Gr-r-r-rreat it is. I found myself using it all over the place, meaning far less spaghetti code. - Test-based coding. Whilst creating the aforementioned classes I used simple agents right from the get-go to test each piece of code as I went along. This was a real revelation, and not too tedious to do. For example, code like this was handy for testing my
LinkedArray, and adding theasStringproperty was very useful (this simply expresses the array as a flat string with a specified delimiter):
Dim LA As New LinkedArray(Null)
Dim i As Integer
LA.add "Winkle"
LA.add "Fe"
LA.add "Fir"
LA.add "Fo"
LA.add "Fum"
Msgbox LA.asString(" ")
i = LA.getIndex("Fo")
Msgbox "i is " & i
LA.insert "Gah", 3
LA.makeUnique
Msgbox LA.asString(" ")
I’ll write more about my experiences should anyone find this useful, but in the meantime, please feel free to chip in with your ideas!
Posted at 12:36 GDT on 16 Apr 2004 | Categories: | (10 comments)

Re. your array class. Kanngard has also written a good "vector" class, amoungst other things.
http://dev.kanngard.net/Permalinks/ID_20020506204851.html
Nick
like the sound of that class, give it up willya?
;-)
Colin, no, haven’t turned to the dark side
http://amano001.at.infoseek.co.jp/LSUnit/
It needs to be run through Altavistas babelfish, but I successfully converted it to a R5 unit testing framework.
- Johan
Seriously good fun, isnt it. Our iDM stuff is now about 120 classes, etc, etc. And this is the only way you can really deal with the stuff.
As a rule of thumb, we generally end up writing as much test code as we do actual code.. Which isnt very good, but does mean that the unit testing works well.
Mmm. A linkedArray class. nice. Especially if it reads and writes directly to and from document items..
---* Bill
LinkedArrayis still being tinkered-with... a few more methods would be nice, then I might expose the soft-white underbelly of my code to wider scrutiny. It’s about time, haven’t posted anything useful in ages!Whenever I muck around with arrays I always fret about
Redims and whether I should be usingLists.Johan [8], interesting link - however, if it’s LSUnit you’re after, check out Nik Shenoy’s site:
http://members.rogers.com/nshenoy0424/code/downloads.html