10 fundamental LotusScript tips

Source: Internet
Author: User
    1.  

      To code

    2. "Measure twice, cut once"
    3. Extending arrays the easy way
    4. Use the list Operator
    5. Logging agents
    6. Code structure
    7. Hiding your code

Fundamental LotusScript Tip #1. Option declare

 

Make sure you always use"Option declare ."It sounds obvious, but there are several determining factors as to why you shoshouldAlwaysUse it. Here are some of the reasons:

    • If you don't use "option declare," all variables are created at runtime as variants, and this makes fact checking redundant.

       

    • Data conversion will cost your company 10 times your performance.

       

    • All your errors will be runtime errors.

       

    • Also, always remember that you shoshould test often and test early. Use the strength of the compiler to help you.

Fundamental LotusScript Tip #2. templates and versions

 

When working with templates and versions in LotusScript in custom code, there are a few things you shoshould always do:

    • Always create templates with new code, which may include databases with an NTF extension or databases with Master Template Name set.

       

    • Make sure you create a separate version for each copy you're working on.

       

    • And always keep your templates and versions in a central repository.

You might say these all sound like good reasons, but why shoshould I use them? There are three major reasons:

    1. Because it makes it much easier to roll back.

       

    2. It helps with version control.

       

    3. It makes it simpler to construct test cases with other versions.

Fundamental LotusScript Tip #3. Application lifecycles

 

When dealing with the lifecycles of your applications, there are a few best practices you shoshould follow:

    1. Always develop in a development sandbox -- a non-production environment where each developer keeps his or her working copy of the code base.

       

    2. Always test in a user acceptance environment.

       

    3. Pass the template to your Domino administrator to copy.

Here is why you shoshould adhere to these Rules:

    • It's a basic change-control system.

       

    • It is you doing your part as a development professional.

       

    • It shakes out hard-coded bugs, such as hard-coded server names, paths and replica IDs.

       

    • It allows you to run extensive testing without affecting your company's production.

Fundamental LotusScript Tip #4. How to code

 

Here are the fundamental how's and why's of how to code in Lotus script:

    • Always code for maintenance.

       

    • Only code for performance if it is required. Make sure you get your code working in general, before you get it working for speed.

Here is why you shoshould follow these Lotus script how-to coding guidelines:

    • The highest cost in development is software maintenance.

       

    • You make it easier for the person maintaining the application.

       

    • You cocould be working on that application!

Fundamental LotusScript Tip #5. "Measure twice, cut once"

 

"Measure twice, cut one" may sound a bit cliche, but it is a good analogy when you are writing LotusScript code. Here are a couple ways it applies.

    • You shoshould always spend more time thinking about what you are coding and less time doing the actual coding.

       

    • You shoshould always try to think of two different ways of solving the problem at hand. The best approach is usually a combination of the two, and you shoshould always think about your data model.

This works well because you are spending more time planning and less time doing actual labor.

Fundamental LotusScript Tip #6. Extending arrays the easy way

 

You shoshould always try to use"Ubound"To establish the size of your array. Below you will find an example of it in use.

Sub initialize () dim myarray () as string redim my array (0) Call myextend (myarray, "hello sailor" ") end subfunction myextend (S () as string, NS as string) as integer if (S (ubound (s) <> "") Then redim preserve S (ubound (s) + 1) S (ubound (s )) = NS extend = trueend Function

If you set up your arrays this way, you won't need to keep a separate index of the array size; it also automatically trims the code. however, there is a minor drawback to implementing this. it will slow down large arrays, so you'll need to define the "empty" value. otherwise, it works great.

Fundamental LotusScript Tip #7. Use the list Operator

 

When you useList Operator, It stores a value with a unique lookup key. It's a good idea to use the list operator because:

    • It's easy and fast
    • It's built right into lotus script (as long as you're using version 4.5 or higher)

Here is some example code:

 
Dim WR list as stringwr ("Peter") = "perfect" WR ("Penelope") = "pitstop" print "Peter's last name is: "+ WR (" Peter ") if not iselement (WR (" dick ") then print" Dick isn't racing! "Forall thisracer in WR print listtag (thisracer) +" "+ thisracerend forall

Fundamental LotusScript Tip #8. Logging agents

 

Another good tip is to log your Lotus script agents, especially if they are scheduled agents. it's also a good idea if you have a broad range of clients. if you do, you need to log both your client and scheduled agents runtime status.

If you don't log your agents, chances are that your applications will break. logging your agents will also help to let you know when your Lotus script agents do break. it's also a good timing metric for performance testing.

Show caution when logging your agents though -- you don't want to make the logging so slow that it affects application performance!

Fundamental LotusScript Tip #9. code structure

 

When dealing with the structure of your Lotus script code, it is usually good to keep it as short as possible. smaller code sequences are easier to deal with and maintain and are easily reusable. A good rule to go by is if your code is more than a screen's worth, you shoshould determine if it is possible to break it up.

Some tips when determining your Lotus script code structure:

    • Try to keep your functions/procedures/classes at a manageable size.

       

    • Think before decomposing problems.

       

    • Don't over comment -- explain your "why ."

       

    • Try to use non-intuitive algorithms.

Fundamental LotusScript Tip #10. Hiding your code

 

When we say we're "ing our code," we're basically saying that we're re decomposing it so consumers can't see it. you don't want anyone to be able to view it, not even yourself.

When you hide your code, you are inferring a logical interface with clear naming. as such, your users and customers can write to the interface but not the Code itself. this is good practice because it simplifies the coding experience.

You can easily hide your code by using "Private/Public" methods in your classes, script libraries, etc.

Tutorial: 30 Lotus script tips

Home: Introduction
Part 1:10 fundamental LotusScript tips
Part 2: 10 everyday LotusScript tips
Part 3: 10 Advanced LotusScript tips
Part 4: More Lotus script Learning Resources

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.