How to write better code in Domino Designer – Part 1

The inspiration to this series of blog entries partially comes from looking at code posted in the developerWorks forums. Some of it is extremely hard to read and understand, even if you ignore the fact that the forum removes indentation from the code. If you write code that is hard to read, your applications will be hard to maintain. Write the code so it is easy for the poor person who will be maintaining the code in the future. Most probably that person will be you. You might also have to post your code in the developerWorks forum or on StackOverflow for help. If the code is hard to read and understand, you might not get very much help. What I will talk about is what you can do to become a better programmer, and write code easier to maintain. After being a Notes developer since 1996, I have learned a bit about what makes a Notes application easy to read and to maintain. I want to share some of my thoughts on this blog, or in the words of Kevin Spacey at Lotusphere 2011: "sending the elevator down". Hopefully it will help someone. I will not talk to much about basic programming concepts or how to program in Domino Designer. I will assume that the reader already knows that, and is familiar with especially Lotusscript. I will also not talk much about how to create applications with a nice and easy-to-use user interface. That I will save for a later series of articles. Instead I will focus on things that I think will make you a better Notes programmer. I don't take credit for coming up with all the ideas I will talk about, some are from attending sessions at Lotusphere in the past, and some were methods I picked up where I work or worked before. Many of the tips are almost defacto standards among Notes/Domino developers. In this first article, I will start with some tips for when you create forms.   Field Names Use field names that makes sense, and don't use cryptical field names. You may remember right now what kind of data the field is supposed to hold, but in a few months, you have no idea what is stored in it. Some developers use hungarian notation or some similar system with prefixes to indicate what is in a field, but in my experience that makes just for massive confusion later. The only prefixes I use on field names are dsp for any computed-for-display fields and flag for fields that are used to indicate if a document has been processed, is ready to be deleted or to decide if parts of the form should be hidden or not. If you use field names that indicates what kind of data types they contain, be consistent and at least use proper indicators. It is not a good idea to call a field txt_no1 if it contains a number. Anyone that sees that field name will assume it is a text field, and this will cause errors…

18 Comments

IBM Notes and Domino 9.0 Social Edition

This morning, IBM presented the latest version of Notes and Domino. The new product name is IBM Notes 9.0 Social Edition. As you notice, the Lotus name is now gone, and the look is changed to look more like other IBM applications, with a more modern design. There are also changes and updates to the user interface inside the different parts of the client.   One thing, totally new for Notes, is that tutorials and training videos are available in the client.  The tutorials are not just for new functions, but also older tips and tricks that will make the users more productive. During the presentation, new functions in mail and calendar were demonstrated. One function that will surely be popular with users is to group mail by date: Other new features shown were the ability to color code different categories of meetings using custom colors and improved monthly view, as well as a weekly planner taken from Organizer. The activity stream is using the OpenSocial standard, and Domino is now supporting OAuth and SAML for authentication. Customers can however deploy Notes 9.0 without the Social Edition functions, and add them later. Not only has the traditional Notes client been updated, iNotes is also updated to look even more like the rich client. One of the biggest news in this version is the Notes browser plugin, that allow user to run traditional Notes applications directly in the browser, in full fidelity with no Notes client installed. The new version of iNotes also contains the new activity stream, as shown in the image below.   The new version of Traveler will (in addition to iPhone and Android) also support the Blackberry 10 platform and Windows Phone 7.5/8, and now also be available for IBM iSeries. A public beta version of Notes 9.0 Social Edition will be available December 14. For previous versions of Notes, since (if I remeber correctly Notes 5), IBM have been doing managed beta testing and not released public beta version. The final version is planned for Q1 2013. IBM also outlined the future roadmap for the next couple of years, which included a new major realease in 2015:

4 Comments

Welcome to my new blog

After having my blog hosted by Lotus911 (later GBS) at bleedyellow.com for almost five years, I have decided to switch blog platform. The main reason is due to limitations in IBM Connections as a blog platform (no anonymous comments and issues for example when trying to embed videos). I decided to go with WordPress as my blog platform, as it is common and widely supported. Another advantage with a WordPress hosted blog that is that I now can have the blog hosted under my personal domain, as blog.texasswede.com. Earlier today I imported the existing content to the new blog. I will write about that process in another blog entry shortly. Basically I wrote a couple of Lotusscript agents in Notes and retrieved the existing blog content and then reformatted it for WordPress. As I did not have very many comments, I did not import them, as I decided the amount of work was not worth it. They can be found on my old blog, as I will keep it alive. That way all the links to it from different placs will also continue to work. I have not verified all old entries, so if you notice anything that need to be fixed, please let me know. One known issue is when I reference another blog entry, the link will currently take you to bleedyellow.com. Again, a big thanks to GBS who hosted my blog for the last five  years, and who got me into blogging. I had made some attempt prior to 2008, but never got motivated enough. Hopefully the switch to WordPress and the greater possibilities will lead to me blogging more frequently than lately.

5 Comments

Things to think about when programming in Notes

Inspired by some of the posts in the DeveloperWorks forums and on StackOverflow, I thought I would post some more basic concepts and how I handle them. I am not saying my way is the best way, this is just what works for me. I am sure there will be more posts in the future"..." I will also mention a few other things I noticed while reading the code posted in the forums.   Retrieve something that doesn´t exist The question is how to identify what dates there are no documents created for. This is where lists are very useful. Richard Schwartz answered this question and posted some good code. Rich suggests to create a list of dates, with each list item having an initial values of false, and then loop through the documents. As each document is processed, the value of the corresponding list item is changed from false to true. You can then go through the list and see which dates still have a value of false, those dates are missing documents. My version of the same code is to actually delete the list item you have a match for, instead if setting it to true. In the end you have a list of just the items of dates without a corresponding document.   Write readable code This could be a blog entry all by itself. But I notice that much of the code in the DeveloperWorkds forums is hard to read"´". Partially because any tabs or multiple spaces used for indenting the code is stripped out, but also because the posters don´t write easy-to-read code. Variable names are often not descriptive: Dim db1 As NotesDatabase Dim db2 As NotesDatabase vs Dim thisdb As NotesDatabase Dim nabdb As NotesDatabase Which one is easier to understand? In my opinion (and I am sure you agree) the second variant. Also function names and other variables should be named so you understand what they do and what kind of data they contain. Comments are mostly non-existing. It is not that hard to add some comments to the code that explain what the code is doing. But don´t explain every line of actual code (it should be self-explanatory, if variables are named correctly), explain what a particular section of code is intended to do. Here is a section of code from an agent I wrote earlier this week: '*** Read PhotoUNID field in LossControl document'*** and build a list of the UNID values in the fieldphotoUNID = lcdoc.GetItemValue("PhotoUNID")(0)If photoUNID<>"" Then '*** Create array of values and put into photolist tmparray = FullTrim(Split(photoUNID,";")) ForAll t in tmparray If t <> "" Then photolist(t) = t End If End ForAll End If The comments above will help the next person to look at the code to quickly understand what it is intended to do.   More on variables Use Option Declare/Option Explicit. This will find many errors, especially for more inexperienced programmers, where variables are misspelled or missing, something that is a very common…

0 Comments

Review: LEGO Lord of The Rings

This weekend I spent with my son building some of the new LEGO kits from the new Lord of The Rings series. Here is a quick review of the kits we have built this far. You can click on the images for high-res versions of them.   9469 Gandalf Arrives – 83 pieces A small but nice set. Contains Gandalf in his cart loaded with fireworks, as well as Frodo welcoming him. Plenty of nice details, like the fireworks, a carrot for the pony and an envelope for Frodo to put the ring in.   9472 Attack on Weathertop – 430 pieces This is a very nice set. It contains five minifigs: Aragorn, Frodo (with the ring), Merry and two Nazgûl (ringwraiths), as well as two horses. The three first minifigs have a feature I have not seen before, they have two sets of faces. By turning the head and exposing the part hidden by the hair, you get two different facial expression, like stern and aggressive or scared. The Frodo minifig in 9460 got the same feature, but not Gandalf as the back of his head is visible. All the minifigs are extremely detailed, it is obvious that the designers of the kits realized that collectors and adults will buy these kits.   The kit itself is of the ruins on top of Weathertop (Amon Sûl), and it features a trap door and a cooking fire. The ruins can be opened and in the inside you find weapons, toches and much more. Even a rat! There is also a stand-alone pieved of ruin with a bush and some plants. The plants are the only thing I did not like with the kit. For some reason, perhaps the kind of softer plastic used, they don’t stick well to the bricks they are placed on. But that is a minor detail, otherwise this is a great kit.   9473 The Mines of Moria – 776 pieces This is a big set, the second largest in the series, and it depicts the events in the Chamber of Mazarbul. It contains six minifigs (Gimli, Legolas, Boromir, Pippin and two Moria orcs), as well as the cave troll. There are four separate sections, a large wall section, the doors to the chamber, the well with the skeleton and the chain and bucket, as well as Balins tomb, containing the skeleton of Balin. By pulling a lever, the skeleton, bucket and chain will fall down in the well, just like in the book and movie. There are plenty of details, from old weapons to gems and even the Book of Mazarbul.   9476 The Orc Forge – 363 pieces This is currently my son’s favorite kit. It features a light brick, so when a rod is pushed, it looks like fire under the melting pot. In addition, there are four minifigs: Lurtz, two Mordor orcs and one Uruk-hai. To be really picky, Lurtz was created by Sauron, just like the Uruk-hai, so there should not…

0 Comments

End of content

No more pages to load