August 31st, 2005

Using code headers to make LotusScript easier to maintain

This article is an example of a simple technique that, when put into practice, can make LotusScript much easier to maintain. Code headers are text comments at the start of procedures that describe what the procedure does, what is passed in, what it returns, any special notes and a brief summary of changes. When you open a function or sub with a code header you immediately know what the code does because it is clearly explained at the top. No more hours of studying the code to figure out how it all fits together.



Function RemoveFolderFields(doc As NotesDocument) as Variant
%REM
=========================================================
PURPOSE
This function removes the hidden $FolderRef , $FolderRefId, $FolderRefFlags fields from the doc

PASSED
doc - The current document we are updating

RETURNS
True - We updated the DocFoldersTX field
False - There was no change to the DocFoldersTX field

SPECIAL NOTES
Checks the exisitence of folders that are in $FolderRef field and updates that field with folders that are present in the database.

HISTORY
25 Jun 03        Prasad KVS -         Initial version
12 May 04        Chris Doig -          Removed references to OldDocFoldersTX. Also deleted commented out old code.
=========================================================
%END REM
Your code goes here...



Purpose

The purpose paragraph explains why the procedure exists. Well written purpose paragraphs save hours when debugging complex programs.

Passed

On occasion I have opened the code starting with pages of global declarations. Such code is easy to write, but difficult to maintain. When debugging such code you have little idea what is changing those global variables without extensive study of the code. My preference is to avoid passing via global variables, to pass everything though the calling line, and fully describe each item passed. (There is normally no need to describe the variable type, because that is defined in the first line of the procedure. Don't duplicate information - you can never manually keep it up to date.) The passed paragraph describes what is passed into the procedure. This can be another time saver, especially variable names are reused, e.g. exactly which document does doc refer to?

Returns

The RETURNS paragraph explicitly states what the function should return. For example, if the returns paragraph stated the function should return true or false, and something else was returned, you would have a good idea of where to start looking for the bug.

Special Notes

The special notes paragraph describes anything unusual about the code, e.g. why a particular approach was taken. It can also be used for programming notes, e.g."if the folder name is missing, then an error occurs that is not caught by the error handler."

History

The history paragraph is simply a list of dates, programmer names and change summaries. This is particularly useful when projects mover around between several programmers - one can always ask a previous programmer why something was done that way.

An IT department could define a corporate standard that requires all LotusScript code to include code headers, and these headers be maintained. Such a standard helps you climb the CMMI scale. (Of course you have to enforce the standard, or it is worse than useless!) Developers can use something like Teamstudio Snippets (or even a home grown tool) to add this code header to the start of every procedure in LotusScript. You can also configure automated testing tools (e.g. EasyDesignScanner) to check that the code header is at the start of all procedures. Once you have these code headers in place you will have take a significant step towards making your code more maintainable.



August 16th, 2005

When is a name not a name?

This short article makes the case for two corporate software development standards in a Lotus Notes shop. Although aimed specifically at Notes shops, the principles apply to any development that works with user names. These concepts come from hard won experience and observing first hand problems at clients where they had not been implemented.

Answer to the above title question: When a name is in a text field.

Notes names can be in three different formats: abbreviated, canonical or common. If names are stored in text fields, you never can be sure which format was used. Consequently code comparing names in text fields must make six comparisons to ensure all possibilities are covered. Even if you compare @username with a text field you must make three comparisons to cover all possibilities. If you work with lists of names things get out of hand pretty quickly. A far better approach is to mandate a corporate development standard:

Names stored on documents must always be in name fields, and never in text fields. (Note: author and reader fields are also name fields).

This development standard significantly reduces the complexity of any code working with those names. Of course any name stored in a names field can also be used for things like NAB look-up (e.g. for department, phone etc.) group membership and so on. When displaying names they can be converted from canonical to common or abbreviated formats as required, but the underlying name is always canonical.

If users are allowed to manually enter names in a text field you can guarantee that there will be errors. Apart from simple spelling errors, users are faced with things like deciding if there is a period after the middle initial or not, if there is a hyphen or a space in a multi part name and so on. This naturally leads to the next corporate development standard:

Users must always use a look-up for names, and never be able to enter names directly into a names field.

Names fields must be computed (or computed for display etc.) and must use the "Select Names" dialog box or a custom dialog box which updates the field. Although the select names dialog box allows users to enter a name not in the NAB, they very seldom use this option. This development standard significantly improves the quality of the data in a names field.

There is an exception: when the name being added to a field is not in the NAB, e.g. when adding a customer or vendor contact name to a database. Under these circumstances create a "person" doc in the database, and use that person doc for name look-ups. The person doc can also store other information like email address, phone number, company and so on.

Implementing these two development standards reduces the time developers spend working with names fields by simplifying the code behind them. And simplified code has the added bonus of being more reliable, something everybody appreciates.



August 10th, 2005

Thoughts on Managing In-House Software Development Projects

Managing in-house software development is very different from managing software developed for resale. To be sure, there are many things in common, but there are some very significant differences. This article looks at some of the problems unique to managing in-house software, and offers some thoughts on solutions.

The aim of any IT department is to "solve the customer's problem", either by buying software or developing in-house. Usually it's better to buy prepackaged software because this reduces risk and implementation time, and can supply prepackaged expertise you don't have. But large software purchases require an experienced project manager, or you can be the victim of enthusiastic selling. On the other had, there are times when you will undertake in-house software development, for example

  • No commercial software is close enough to meeting the requirements, e.g. projects that handle departmental workflows. These are typically small, highly specific projects and there are many of them. Typically they are implemented via a web browser or with the Notes client.
  • The project is so small that it would take longer to find and evaluate a commercial product than it would take to develop it in house. This presupposes you have a good developer, good libraries that the developer uses (or a similar project that he is well acquainted with and can copy from) and a rapid application development environment.
  • You have developers with a good track record of successful projects, very good understanding of the problem, and of the technology used. Remember that engineering lore states that when a developer gets to the end of a project, then they know how it should have been done.
  • The commercial package is ridiculously expensive. I once had a case of implementing a certain feature using Lotus Notes. A commercial company quoted me the equivalent of 3000 hours of developer time for a site license. The developer took some existing code and had a similar solution working in less than 100 hours.
The aim of in-house software development is to produce successful projects in a short a time using as few resources as possible. When it comes to measuring the success of software projects all sorts of numbers are thrown about. They range from studies that claim only 25% of software projects succeed, to one IT director who told me that every single one of his software projects succeeded. So what defines success? Is success meeting requirements, or is it more than this? I would argue that a successful software project has all of the following attributes to some degree:
  • The project must be put into production, must meet customer requirements, and must be continuously used by employees.
  • The software must be easy to use, and not require extensive training (Reasonable training is acceptable.)
  • The software must not frustrate users. Users must find relatively few bugs, and they must not loose data.
  • The software must be capable of being extended. When employees start using in-house developed software, it doesn't take long for enhancement requests to arrive. If the project is difficult to maintain and extend, there may be a serious danger of it being only a short term success. So the internal design of a software project is very important.
Now that we have a successful project defined, we need to look at the four elements that go into making a software project successful: Scope, Resources, Time and Quality. Bear in mind that you can never control more than 3 of the 4 elements. Sometimes you can't even control that many!

Scope

A big problem for -in-house software development is project scope. What exactly is going to be done? Project scope should be defined by a Requirements Specification (more in a future article), but often is not. This leaves the way open to scope creep, especially from inexperienced developers who are eager to please. Mr Customer, would you like this feature? It will take no time to add. Usually the answer is yes, and most of the time the developer severely under estimates how long it takes to add. Scope creep is a perennial problem for all software development.

Probably the best way of dealing with scope creep is to push new requests into future releases. You avoid saying no to the customer, yet you are still able to meet the original delivery dates. Frequent small releases allow the customer to steer development as it unfolds.

Resources

When considering resources thoughts naturally turn to outsourcing. While there certainly are projects that can be successfully outsourced, I think that it can easily be a disaster. The main problem is communication between the developers and the customer. It is very important to have the project lead developer talk face to face with the customer. By all means have the developer's manager in meetings etc, but the lead developer must take final responsibility for communication - the manager acts only a facilitator. One on one communication and an immersion the corporate culture give in-house developers a much better chance of developing a successful project.

While offshore developer teams loose out on face to face communication, they also loose out on phone conversations. Usually there is a language or accent barrier, and often a time zone barrier as well. While offshore teams can meet requirements specifications, you can still have a project failure on your hands. I tend to think that offshore development works best where there is a well defined project specification, and continuous communication is not really required.

Whether a team is local or off shore, small, tightly focused teams of excellent coders will be orders of magnitude more successful than larger groups of average coders. Always bear in mind that when you add new people to a project, you increase the communications overhead; there comes a point where adding new coders can actually slow the project down.

In any IT department there tend to be a few large software projects and many small ones. One problem that occurs when you have individual developers working on small projects is they can go off on tangents. These tangents range from a non-optimum architecture though to spending significant time on something that is not project related at all. Here is a lesson I learned the hard way about software architecture...

Many years ago I was managing a developer who was writing software to capture measurement log output of production line machinery (they were making small metal objects on the production line). This software tracked tolerance trends, and if they drifted too far in one direction would shut the line down and prevent scrap from being manufactured. In those days disk space was expensive (I did say this was a long time ago!) and the developer came up with a complicated relational structure designed to reduce disk space. The developer overhead of maintaining this structure was so high that it doomed the project. Looking back I learned several lessons that apply to in-house developed applications:

  • As a project manager pay close attention until you are satisfied with the software architecture and the work done.
  • Hardware is much cheaper than software development. Always design to reduce software development costs, not hardware. (Also you usually should design for easy of maintenance, and not speed of the code).
  • When logging data, you don't need (or even want) a relational structure. The overhead is not worth it.
  • The simplest solution is usually the best.
This experience taught me why it is vital that as a project manager you know and understand your developers. If you understand the architecture and can suggest alternatives, you are ahead in the game.

Another tangent is having a developer get side tracked by something that interests them, and loose focus on the required project. While it is important to maintain a developer's interest in a project, discipline is also required. If this gets too far out of hand, the only option may be to let them go, not a pleasant thing to do.

Finally, while priorities do change, as far as possible avoid rapid switching between projects. It seriously reduces a developers effectiveness.

Time

Usually time is the toughest element to manage. One technique is to set frequent, small milestones. This avoids the problem of having a project at 95% done for weeks or months. Then when reality strikes at the last minute it drops back to 50% done.

Another technique is small, frequent releases to production. This  leads to a much higher customer satisfaction than few larger releases. And they allow the customer to better steer the direction of the project.

Always remember to build in contingencies for those unknowns that creep into any project. For example, never budget on a programmer spending more that 75% of their time on their "top" project.

Quality

How well does the software meets the customer's real needs? The problem is a customer sometimes can't articulate those needs very well. Also things come up in a project that nobody can possibly predict at the start.

Good (user) software requires a good interface. Remember that developers are code artists, not graphics artists. A developer can spend weeks tweaking a user interface (UI), and still end up something totally unusable like with red text on a blue background! Contract with an experienced a graphics artist / UI specialist. It is often cheaper, especially when you take the reduced training costs into account. While code reuse is very important, how many people consider UI reuse? Develop a standard user interface theme for all your projects, and free your developers from designing a new UI for every project. Not only do you save developer costs, but you reduce end user training costs as well.

The rate at which the customer finds bugs in production should be minimized. Of course software should include error handling, and part of that error handling must notify the developers when something goes wrong. Log the error to the database, and send an email to the groups responsible for the software. (Note: the error handling in production databases should always use a group, and not names. When people leave the company it is much easier to find all the groups they belonged to and update the names. If names are recorded in the database, these names often don't get updated, and the errors are missed.) When developers are notified by email they will often fix the problem before the end user even notices it. Also, because they don't like being pestered by error notifications, they try to solve the problems that cause the errors in the first place, in effect climbing the CMMI ladder. This is exactly what Microsoft and others are doing when a program crashes and Windows asks if you want to send an error report.

Reducing project risk

There are many articles on reducing project risk on the web, so let me simply summarize a few simple rules of thumb here

  • Minimize the unknowns. Go though the project looking for things you don't know, and get rid of them. For example, reduce the number of new technologies, and match developers to the technologies proposed.
  • Define the scope of the project well. Minimize scope creep. When new requirements push the scope, put them in a future version.
  • Make frequent, small production releases so the customer can steer the development direction. For Lotus Notes development, this could easily be as often as once a week.
  • Simplify. To paraphrase Occams Razor: when faced with several similar choices, choose the simplest. Why? Well, if you made a wrong choice and you chose the simplest, it means you throw away the least amount of work.
  • Reduce coupling between parts of the project. It is a lot easier to make several little widgets that one big widget. It is interesting to see Microsoft go against this with Exchange 2003 which requires active directory. Linking Active Directory to Exchange has made it so much harder to deploy that two years after the introduction, less than 50% of the customer base has upgraded.

A Few Final Thoughts

We all know the story of the carrot and the stick. Simply put, you are in a much better position when employees want to use the new system, rather than forcing them to use it. And you can reach that heavenly state of project manager bliss by following one simple rule: You must deliver more from the new project that the old way cost. Whether the old way was a manual method or simply an outdated system, the new way must have a reward/cost ration greater than one.

When rolling out a new project, identify the "opinion leaders" amongst the users. If you can get them to endorse the project you are well on your way to a success. Bear in mind that they are not the actual customer, but are members of the user community. Although conventional wisdom says "start with your least critical users", it can be a good idea to roll it out to the opinion leaders first.

  • You have the time to hand hold them while bugs are worked out.
  • They feel important, part of the team. They build in a commitment to the success of the project.
  • When others see the opinion leaders endorsing the project, they tend to follow. The first time I did this, I even had end users asking when they would be upgraded.
Never forget end user training aiming to train at least 80% of your users. It can make or break a project. Of course having decent user help is also important (user help techniques are the subject of a future article).

I hope these thoughts and real world anecdotes give you some good ideas and help you make a success managing in-house software development. projects.

Acknowledgement: I am indebted to Ray Hoving of Ray Hoving Associates for some of the ideas in this article.



August 6th, 2005

Using Version Numbers to Manage Database Designs

Notes templates are marvelously powerful. But that power comes at a cost - templates and database designs must be managed effectively. For any given inhouse developed database, how you do know which version of the design is in production? While this is a problem on servers, it can be a much bigger problem with remote users who replicate databases down to their laptops. When they call the helpdesk, how does the support person know which version of the database is being used? Multiply this by the thousands of databases used at a typical corporate site, mix in a few replication problems and you have a nightmare.

One solution is to use a configuration document to track the database version. This document is updated with the new database version number whenever a new design is pushed into production. With a one-to-one relationship between development and production databases, it is difficult to keep everything in sync. Whith multiple databases from one template it becomes almost impossible. Some people try to track database versions by looking at the date and time on design elements. This is really clumsy and only works on the server;  it fails on a remote laptop if the user doesn't have the designer client available.

How much better it would be to have the design stamped automatically with the template version. To do this you need a design element (as opposed to a document like the configuration document above). The last design step before pushing a new version of the code is to update the version number of the design element. While a page or form could be used, typically a shared field is used because it is more flexible. Since a shared field is a design element, it flows into the production database during a design refresh, like any other design element. This unambiguously identifies the design version being used in production and very neatly solves the problem.

Implementation


In R5 you would use a computed shared field, and set the value of the field the release version, e.g. DocMaster R4.0.40. Release 6.5 moved this idea into core Notes functionality, and you can see an example of it in the mail file. Look at the mail file's Database properties... Design properties (middle tab) and you will see a version number something like 6.5.4 (03/09/2005).  This information comes from a shared field called $TemplateBuild. The example below is from a database called DocMaster. Notice how this production database is based on the master template DocMaster R4 PRD, which is in turn based on the development template DocMaster R4 DEV

DbPropertiesDbVersion.gif


If you look at the properties of $TemplateBuild shared field in designer (see below), you will see 3 items on the design element document. (Note: Just like normal documents have items, so design elements have items.) You can access the template version number with a new @function, @TemplateVersion. (Unfortunately there is a bug: @TemplateVersion doesn't work in computed text. You must use a computed for display field).

SharedFieldDesignElement.gif


You can use the new R6 NotesNoteCollection classes to manipulate these item values. I have written a small database Set Template Version (see download link below) that allows you to update these 3 items. Launch the database and follow the instructions in the diagram below. If the $TemplateBuild shared field is not present, it is added to your database.  (Note: if you use Teamstudio CIAO you may get prompted to check out the design element. Select yes, and then use CIAO to check it back in again. This should be the last step before making the new version of the database.) Be aware that the master template does not show  the version information on the design tab of the database properties (because it is not inheriting a design). However, any database that inherits from that template will show the version information on the design tab.

SetTemplateVersion.gif


If you launch Set Template Version from the designer client, you can see templates as well as databases when you click the Click to start button. To launch form designer, create a new button on the toolbar, and give the button the formula

@Command([FileOpenDatabase]; "Dev\\Projects\\TemplateVersion\\TemplateVersion.nsf")

Replace the path above with the path to the database on your system. Thanks to Chad Schelfhout for this suggestion, and for pointing out an error which has since been fixed.

Click link to download file
TemplateVersion.zip



August 4th, 2005

Welcome

Posted at 11:00:00 AM in  General | View Full Comments Inline (0) | Welcome

Aah - the obligatory welcome page. This blog is about  my thoughts on collaborative computing, mainly on the Lotus Notes / Domino family of products. I am also very interested in the management of collaborative computing - how to effectively use collaborative computing to improve the bottom line of the business. I hope to publish at least one article per week, if time allows.

In one way, this blog is a collaborative computing effort - you could say I'm eating my own dog (Doig?) food. I long ago found that no matter how much I know, there is always plenty to learn from other people. My hope is that the articles published here will stimulate comments that add to their value, so we all benefit.

Of course my comments in this blog represent my own options only, and not those of any employer or customer, past present or future.



August 1st, 2005

Contact Me - Updated 2/11/2007

Email: chrisdoig-at-yahoo-dot-com

Cell: (760) 470-2011
Skype: chris.doig



August 1st, 2005

About Me - Updated 2/11/2007

Here is a little auto-biographical background to put some context around entries in this blog of mine. Since a kid I have always had an interest in hardware and software. This led me to study Electrical Engineering at the University of Cape Town, South Africa, and I graduated with a Bachelor of Electrical Engineering in 1989. While studying, I started a computer company, Cirrus Technology, which I ran until 1991. We focused on the corporate market, supplying hardware, networking and software. We also developed software for a number of corporate clients using Clarion (now SoftVelocity)  - an advanced database tool in those DOS days.

After Cirrus I took a job as IT Manager (equivalent to an IT Director in the US) at the Medical Research Council of South Africa, and later a position as a System Development Manager at Plessey South Africa (now Tellumat). After working at Plessey for almost 2 years opportunity knocked in the form of a "green card" - the right to work in the US for any employer. Being the adventurous sort (I was a hang glider pilot for 10 years) and having always wanted to "see how the other half lives" my wife and I decided to emigrate. We felt that if we didn't like it, we could always return. But we have enjoyed living in the US immensely since 1995.

Emigrating was quite a change. While the lifestyle in California was very similar to Cape Town, the culture was surprisingly different. On arriving in the US I started job hunting over the internet, and four weeks to the day later I started at Seagate Technology in Scotts Valley, California. Early in 98 the CIO at Seagate, Tom Dillon, left and joined Candescent Technology. A few weeks later Tom approached me and asked me to set up the Lotus Notes environment at Candescent from scratch. I jumped at the opportunity, and stayed with Candescent for 4 years until they ran out of money - a Silicon Valley startup that didn't quite make it. I then joined Idec Pharmaceuticals at a Senior IT Manager. That was my dream job, perched on the cliffs at Torrey Pines, in San Diego. Two years later Idec merged with Biognen (now BiogenIdec), which prompted a change in direction to that of an independent consultant.

My primary interest is the intersection between the business and IT, or applying IT to solving business problems, and empowering people. Over time my interest and skills have developed, constantly improving ways to efficiently manage IT teams to delivering value to satisfy customers.

Chris.JPG
Hard at work...