Ben Poole

“It is a very sad thing that nowadays there is so little useless information.”

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? [smiley Smile] 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 FormValidator class 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 LinkedArray class. 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 the asString property 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!

Comments

  1. Ben,

    Re. your array class. Kanngard has also written a good "vector" class, amoungst other things.
    http://dev.kanngard.net/Permalinks/ID_20020506204851.html

    Nick

    nick, 16 Apr 2004 (#)
  2. Ben, if you ain't doing MPB stuff (you lucky fish), what are you working on these days?
    Colin Pretorius, 16 Apr 2004 (#)
  3. Mainly my coffee drinking skills [smiley smile]
    Ben Poole, 16 Apr 2004 (#)
  4. i'm actually having a hard time lately writing lotusscript code that isn't OO. i've got the bug!

    like the sound of that class, give it up willya?

    ;-)
    jonvon, 16 Apr 2004 (#)
  5. Ben: project management? :-P
    Colin Pretorius, 17 Apr 2004 (#)
  6. I really like the sound of test based development. Particularly if it leaves me with a kind of jUnit kind of test harness for the Business Logic of the application. This would be just dandy for integration testing n'all. Trouble is that in most Domino applications you can't really use too much lotusscript beacuse the agent manager will kill you. I struggled with Kent Beck's book but there is some good stuff at www.testdriven.com
    Spug-Me-Not, 17 Apr 2004 (#)
  7. Agreed Spug-meister, you don’t want loads of agents everywhere. But in the testing / dev cycle that’s OK.

    Colin, no, haven’t turned to the dark side smiley wink This was just the first “greenfield” Notes development I’ve done in ages. Most stuff for me now is tinkering, managing others and Java coding.
    Ben Poole, 17 Apr 2004 (#)
  8. For a JUnit-like environment, check out LSUnit at:
    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
    Johan Känngård, 19 Apr 2004 (#)
  9. I think I see a problem with the test - "Fir" should surely be "Fi".. [smiley smile]

    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
    Wild Bill, 19 Apr 2004 (#)
  10. Well-spotted Bill [9] smiley wink The LinkedArray is 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 using Lists.

    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
    Ben Poole, 19 Apr 2004 (#)









(HTML OK. Line breaks & links converted, so don’t use anchor refs)