Best practice (Part 1)
Written by Ben Poole on 03 Jul 2002
Categories / keywords: Best practice, centralising code
(click on a term to search for related articles at this site)
Background
There's far too much sloppy Notes & Domino development going on out there. Code is splashed around all over the NSF, no thought has gone into database structure, performance considerations, and so on. This occasional series aims to address this! Part 1 covers centralising your code.
Introduction
How did you come to Notes development? Were you a programmer forced to use Notes when an employer moved to it? Were you a Notes "power user"? Did you just fiddle with it in a bid to pass some exams? Perhaps you were a sys admin with ideas above your station?
Notes is a funny old environment for development. It started out as an extremely proprietary product, a "niche" database application, and has developed into much, much more.
But it's a dangerous development environment. Why? Because of the way code can be so widely distributed within a Notes application.
You can nest code in to form, page and view / folder events. You can tuck it away in agents, shared actions, buttons, hotspots, outline entries, database events.. the list goes on. But just because one can doesn't mean one should.
Why centralise your code?
In a word, "maintainability." Scattering code all over a Notes database does not a happy developer make. Try tracking down that elusive bug. Ever inherited a badly-put-together database? I know I have. Many times. Troubleshooting becomes infinitely less painful when the code is in just one or two places. The advent of shared actions in R5 and script libraries in R4 have helped developers centralise their code, along with other Notes constructs such as sub-forms and agents. Use them!
How should I centralise my code?
There's no point being prescriptive here. Programmers are a notoriously pig-headed bunch, and everyone thinks that their way of doing things is the best. However, I have found that certain rules have helped me no end, and they do seem to really make sense:
- Shared actions
- Form events
- Use script libraries
- Consider a "strings" script library or document
- The database may get translated one day. It's always easier to have all the user-facing text in one place, whether it gets translated by a person or Workbench etc.
- I can edit and review my user messages all in once place
- I can re-use messages and strings (e.g. I always have the same generic text for Messagebox and Dialogbox titles)
An example "libStrings" script library is attached as an LSS file. Simply create a new script library, and then using File / Import, bring the LSS code into it. Have a play, see what you think.
Attachment(s): libStrings.lss (4 KB)
» Best practice (Part 1) (Ben Poole 03 Jul 2002)
... Re: Best practice (Part 1) (Mike Bigg 19 Aug 2002)
... Response to Mike (Ben Poole 19 Aug 2002)
... Re: Best practice (Part 1) (Mike Bigg 19 Aug 2002)
... Re: Best practice (Part 1) (Ben Poole 19 Aug 2002)
... Re: Best practice (Part 1) (Anura Samara 19 Aug 2002)
... Re: Best practice (Part 1) (ginger binger 22 Sep 2002)
... Don't worry Dave... (Ben Poole 23 Sep 2002)
... Re: Best practice (Part 1) (Chris Molloy 19 Oct 2002)
... Re: Best practice (Part 1) (nick 4 Dec 2002)
