The wrapper classes I blogged about in February went down a lot better than I thought they might.

So, taking it further. Let's extend the DocumentWrapper class some more. Since first writing about them on here I've been busy using and extending them as I go. Here are a few examples of some of the properties I've added

These don't do anything that can't already be done. They just make it simpler and quicker to code.

Logging Document Actions

Properties are all well and good. But they're just borne of laziness really. Let's add a method or two, to make it really useful. How about adding a new method to the base class called LogAction() which you might use like this:

invoice.LogAction("Invoice Approved")

And the method might look like this (it assumes all your Forms have a standard field called "ActionLog"):

Extending Derived Classes

So far I've talked about extending the base DocumentWrapper class. Everything we add there is available to all classes derived from it. But, obviously, you can also add properties and methods to the derived classes. For example, the Invoice class might want an Approve() method. This could either simply flag it as approved or perform some more complex workflow logic, passing it between approvers.

Notice I added a call to LogAction() inside the Approve() method. That way you never forget to log the approval no matter where you call the Approve() method from.

The possibilities are almost endless.

Summary

These wrapper classes have completely changed the way I code my Domino web apps! My dream has always been to be a "proper coder". I'd love to be able to work completely in Visual Studio writing C#. Unless you've done that you won't appreciate what a pleasure it can be. I get a buzz from writing my own classes and then using them. This is a buzz I've never really had while coding for Domino. Until now. These wrapper classes will have to do for the time being.

Next week I'll talk even more about them and show how to handle collections of documents that belong to other documents. While I go, I'm working on a demo app that brings it all together.

I should have learnt by now not to post LotusScript code that I wrote "off the top of my head" in a text editto. I've done this in the past and been shouted down for it. Should only ever post code I've "compiled" and tested...

Interesting that the Delete() sub is reserved. Didn't know that. Probably could have guessed though. Doh.

Now, that's a refreshing change. Nice to hear from somebody down at my level who is learning from what I write. Rather than only getting feedback from the know-it-alls who want to point the errors of my ways (I openly welcome any corrections to what I write but can't help sensing a smugness about it sometimes).

It's always been a bone on contention for me that learning to code in Notes properly comes with very little decent help. I guess the way to have done it would have been to read some good books on (Visual) Basic and imply from them. Oh, how I wish I'd done that ten years ago....

Dude, don’t sell yourself short. I’m pretty sure that these posters don’t know half of what you know. I’ve been doing Domino/Notes development for almost as long as you have and I’m always learning new stuff from your blog. The posters are also learning new stuff from you too, even if they seem smug, or they wouldn’t be returning. You have the most popular Domino/Notes development blog for a reason.