Thursday, July 1, 2004

A quick way to turn debugging on and off using the ACL

THIS WEEK'S POWERTIP

By Mick Moignard

Many years ago, I learned a life tip that has stood me well over the years. It's to be ready and willing to learn from everyone you meet and everything they say. There are always opportunities to learn something new, if only your mind is open and ready when the opportunity arises.

And that's not just in your work, but also in your family life, hobbies, whatever, and at any time.

All it takes is to listen to people just a little more carefully, and you will come across real gems. Maybe not very often, but they do happen, and in unlikely places and from unlikely sources. You get them from friends, work colleagues, your kids, other people's kids. And often from people who you might not expect to get such ideas from.

What prompted writing this was doing an interview recently, for a Domino developer for the project I'm currently working on. Normally, at an interview, you don't expect to pick up new knowledge yourself. After all, you are selling a job to the interviewee and he's selling himself to you. We were talking about debugging techniques, and he suggested something I'd not thought of. I filed it away mentally as a useful idea, reminding myself that if I'm not mentally ready to learn in any situation, I'd have missed it.

And here's the Notes tip that came from that idea. When working on complex code, it's often useful to be able to switch on or off some sort of debugging output.

The original tip was to use @UserRoles output to determine whether to @statusbar or @prompt debugging info during a piece of formula code just by whether you are in a role called, say [Debuggers]. Then, all you need to do to turn it on is to add the role to the ACL (Access Control List), and add yourself into the role.

Quite a neat idea, because you can turn it on and off without changing the code. You can also extend this idea to LotusScript and Java. All you need to do to do this is to Get the NotesACL for the database, get the NotesACLEntry for the NotesSession.EffectiveUserName -- which is the person or server running the code -- and see if the NotesACLEntry.Roles contains the Role called, again, say [Debuggers].

If so, then do whatever you do to display or log debugging output.

Remember, keep an open mind. It might just save you some coding time.