ShowTable of Contents
Previous |
Next
In this section we have a look at how you can fine-tune your coding and development process to optimize your application development and its performance.
Coding practices
Best coding practices for software development can be broken into many levels based on the coding language, the platform, the target environment, and so on. Using best practices for a given situation (in our case Domino and XPages) reduces the probability of introducing errors into your applications, regardless of which software development lifecycle (SDLC) model is being used to create that application. In a team environment, best coding practices ensure the use of standards and uniform coding, reducing oversight errors and the time spent in code review.
Some of the best coding practices that you can use are:
- Use a uniform standard and naming convention across all the code.
- Have code reviews involving multiple developers.
- Unit test all code.
- Have proper documentation, including generous amounts of code comments.
- Use script libraries to prevent duplication of functions, constants such as view and item names, and common datatypes and enumerations.
- If you write LotusScript or JavaScript, use object-oriented coding techniques.
- Avoid goto statements and overly deep levels of nesting.
- Limit modules to a reasonable length; generally not more than 60 lines.
- Simplify and optimize your code as much as possible.
- Remove unnecessary code before deploying.
- If you write LotusScript, use Option Declare, which cuts your initial coding errors by half. There's an option in the editor which automatically inserts this statement for you.
For general coding best practices, we recommend doing some reading on the subject, for instance in such works as
The Elements of Programming Style by Brian W. Kernighan and P. J. Plauger.
We discuss more about XPages development best practices in
4.6 Optimizing XPages using custom control.
Version management
For an effective tracking and proper maintenance of your code, you should use a version management system for your applications. In Lotus Domino Designer 8.5.3, a new source control feature has been provided which helps you to do version management out of the box without using the external plugin that you had to use earlier. This feature has been introduced to let you store NSF based design elements into a source control repository and perform common source control operations using Lotus Domino Designer. Using this feature, you can create an association between an on-disk project managed by the source control and the virtual NSF based project that your Designer recognizes and tracks.
To use this feature, follow these steps:
- Install and configure the open-source version source control systems and create and configure a repository.
- Associate your application (NSF) with an on-disk project (ODP) or create a new one.

- Commit your changes from Designer on-disk project to the repository.
- Ask your team to retrieve on-disk project from the repository and associate their databases with the on-disk project.

- Modify either NSF or on-disk project (ODP) and synchronize the two files.

- Commit changes to repository and ask other team members to download and sync their local files.
Unit testing
Unit test is the first and most important level of testing in the software development lifecycle. It is usually done by the programmer, and it is their responsibility to make sure that their piece of code passes through without any errors and is compatible with the rest of the application. You can save a lot of effort and resources in the long run if all the programmers in your team do their quota of unit testing thoroughly.
In order to make the unit testing effective, first of all, make sure that it is followed rigorously by all the team members and have and allot sufficient time for them to test.
You can refer to this link for details on what, why and how of unit testing
http://en.wikipedia.org/wiki/Unit_testing.
The Domino open source website, OpenNTF.org, contains
multiple projects with free tools to assist in unit testing of Notes and XPages applications.
Parent topic:
2.0 Application development lifecycle