Why Use a Script Library?

I’ve been developing applications in Notes for a while now and have yet to use a script library. I’ve created plenty of agents, script etc, but I guess I’m not quite sure when it would be helpful to use a script library. I can understand if I had a function to call from several forms or something like that, but other than that, why would I use a script library? Are there advantages to doing that if the code isn’t going to be reused in multiple places?

Just trying to make sure I’m doing things the ‘best’ way. Thanks for any info!

Subject: Why Use a Script Library?

Reusability is the biggest reason, followed closely by OO use and structs/types. Since the definition for classes and user-defined types in LotusScript have to appear in the Declarations section of code, there’s no good way to make them individually available the way that functions and subs are. (We’ve asked for it over and over again, and seem to be getting some action for the Designer 8 client, but until then …) Notice that in the mail template, each of the classes used in the LS is in its own script library – that’s really the only good way to deal with classes and large types.

Subject: Why Use a Script Library?

This is from a Redbook:A script library is a place for storing code that can be shared in the current

application using LotusScript, JavaScript, and Java—or in other applications

using JavaScript and Java. Using script libraries allows you to maintain code in

one place.

And here is the link to the Redbook, “Domino Designer 6: A Developer’s Handbook”

http://www.redbooks.ibm.com/redbooks/pdfs/sg246854.pdf

HTH.

Gregg

Subject: Why Use a Script Library?

If you’re not ever going to reuse any of your code at all, there’s not much point in using a code library. However, I find that in my more complex applications, I’m reusing code all the time. Sometimes, there’s code I reuse within the database. Imagine a database which may be used either in the Notes client or on the web. I may have different forms (one for the web, using lots of JavaScript and custom HTML, and one for the client using more conventional Notes objects), but want the documents to be processed in exactly the same way when submitted. I may have different methods of getting to the back-end NotesDocument object, but when I do, I can hand it off to a single function (or batch of functions and subs) in a script library. And if I need to use the same code in scheduled agents as well, it’s right there.

I also reuse code across databases. I’ve got some standard “utility” functions that do things like sort document collections or emulate @functions in LotusScript. I can keep then in a code library which can easily be copied and pasted between databases.

Subject: Why Use a Script Library?

The use of resusable code/script libraries is considered a good process control in an IT Governance framework. Not only does it accelerate development, but it also reduces the likelihood of coding errors when using prebuilt subroutines.

Subject: RE: Why Use a Script Library?

So Java is the best way to use the same code over and over again in R6? (Lotus script libraries being confined to just that application.)

Subject: Why Use a Script Library?

Instead of script libraries, you can also use include files, or use include files in the script library. One problem with include files is that you need the same include file on each installation of notes, where you want to compile your agents. When you use the include files in a script library, you don’t need to recompile the script library every time you make changes in your agents.There is also some limit how much lines of code you can put in a single agent, and when you reach that limit, you have to put parts of your code into a script library. Another benefit of using a script libraries is that your agents compile and save faster, since you need to compile only the agent code.

Yet another benefit of using script libraries would be that if the name of your include files change, you don’t need to change them in each agent, but only once in a script library.

One bad thing about script libraries is that if they grow very big, they can slow down the performance a lot.

Even if you don’t use the same code in multiple places, you will probably still have common parts, like dim session as new notessession, dim documents, views, databases, etc…, with a script library you could write a class which handles the routine initializations, so that you can have just the custom code you need in your agent, and have all the common backend class initializations and error checkings in MyNotesSession, MyNotesDatabase, etc… classes.