I am sure most of you who started programming around the same time that I did (in the first few years of the 1980's) at one point carried something like this in your wallets:
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.
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.
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.
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 reason for posts in the forums.
Another thing that a surprisingly large number of posters seem to struggle with is how to correctly declare variables. I see many cases where several variables are declared on one row, but only the last one has the data type. The author of the code was thinking it would apply to all the variables:
Dim FirstName, LastName, Street, City, PostalCode, State as String
This will declare State as String, but all other variables as Variant. This is not unique for Lotusscript, Visual Basic (on which Lotusscript is based) works the same way.
I always declare each variable on a separate line. This makes it easier to find a particular variable if I am looking for it. I also declare all variables in the beginning of the code/function, again to make it easier to find it in the future. Finally I order the declarations in the same order:
1. Notes UI classes (so they are easy to locate, in case I need to rewrite the code to be used in a server-based agent.
2. Notes backend classes. I always declare them in the order they are being used, as this also is how the classes are structured.
3. Variables and custom classes, in the order they are used.
Here is an example, from the same agent as above:
Dim session As New NotesSession Dim photodb As NotesDatabase Dim lcdb As NotesDatabase ' LossControl DB Dim lcview As NotesView Dim lccol As NotesViewEntryCollection Dim lcentry As NotesViewEntry Dim lcdoc As NotesDocument Dim photodoc As NotesDocument Dim rtitem As Variant Dim rtnav As NotesRichTextNavigator Dim rtlink As NotesRichTextDocLink Dim cnt List As Long Dim photoUNID As String Dim unid As String Dim photolist List As String Dim verifiedlist List As String Dim tmparray As Variant Dim photos As String
As you can see, I also put a comment there, to explain what lc stands for.
I also try to use a list for counters, instead of having a number of separate variables. Doing that makes the code easier to read and understand, despite it actually being longer:
cnt("Total") = lccol.Count cnt("Processed") = 0 cnt("Updated") = 0 cnt("UpdatedPhoto") = 0
cnt("Processed") = cnt("Processed") + 1 If cnt("Processed") Mod 10 = 0 Then Print cnt("Processed") & " of " & cnt("Total") End If
See how easy that code is to read?
I see many messages where the poster is getting an error message, or an unexpected result (or no result at all). Sometimes a large chunk of code is posted, but no indicator where the error happens.
It seems like very few (at least of the obviously less experienced programmers) use the debugger at all. In most cases they would quickly find the problem that way, instead of asking why they get “object variable not set” or “type mismatch” errors somewhere in 100 lines of code”…”
Yes, the debugger has limitations, and it could use some new features (like breaking when a particular variable has a specified value or match an expression), but it is a huge help even in the current form.
Many problems are because the programmer did not understand what data type different functions returns, or even (in some cases) what the different data types means. One poster (I can´t find the post right now) had code like this:
Dim x As Integer x = 0 x = x + 3.5 MsgBox x
He was the surprised that the message box displayed the value 4… I think understanding data types is a requirement of being a programmer, even if the language you work with is forgiving or don´t require variables to be declared.
Another common issue I see is that it seems like the programmer just got an assignment and started to write code, without thinking through what the actual process is going to be. He/she often write him/herself into a corner, or is so focused on solving it with existing knowledge (e.g. “has to be @Formula language”), that the difficulty level of the task approaches impossible. Or the code will be extremely convoluted.
Think through the problem, break it down into small problems/steps. Break each of those down into even smaller steps, etc. Finally you have a good specification, and often even pseudo code. It m
ay be that the user requesting the program/functionality (a.k.a. stakeholder) is saying how he want it to be done, but that is really not the stakeholders responsibility. He/she should just explain what the end result should be, and the developer will design the best solution.
I have examples where a manager comes to me and asks for a report “in Excel” of data in a Notes database. That is because the manager in this case was used to working in Excel, and thought of how Excel displays data as the way he wanted it.
I could very easily create a report directly in Notes, displaying exactly the same information. Since I asked what the end result was supposed to be, and how the data was supposed to be used (and by whom), I could avoid Excel altogether and built a pure Notes solution.
This is where experience comes in, things like that is not something you can just pick up at college/university. If you don´t have the analytical/problem solving skills, you will struggle as a programmer. You might be able to write code under strict guidance, or you might even be able to eventually complete the assignment, but it will most probably not be the best/fastest solution, even if the code will work.
Two good blog entries are Separating Programming Sheep from No-Programming Goats (CodingHorror, July 2006) and Why Can´t Programmers.. Program? (CodingHorror, February 2007). Programming consists of problem solving and analytical skills, fundamental skills (like data types, how functions works, recursion different kind of branching/looping), as well as understanding the language and platform you use. If you are missing any of those things, you will probably not be a very good programmer.
Last night I went to see Looper. I had actually not heard much about it, but I looked it up online real quick and at least it sounded like a good premise for a movie. I have always enjoyed sci-fi, and especially time-travel.
The premise is that Joe is a "looper", a contract killer in a near future (2044). About 30 years after that, time-travel has been invented, but declared illegal. So only the biggest crime syndicates have access to time-travel, and they use it to get rid of people. The send the victim back 30 years in time, bound and gagged with a hood over their heads. The looper promptly kills them and disposes of the body. The looper is paid with silver attached to the victim. Occasionally the future version of the looper is sent back, who kills his older himself. The is called "closing the loop".
Joe (played by an excellent Joseph Gordon-Levitt) is a looper. One day his future self (Bruce Willis) shows up, but promptly escapes. In the future, a new gangster boss, "The Rainmaker" has taken over, and he is closing the loop on all loopers. In doing so, the future Joe lost his wife, and he is now looking to prevent this by finding the young Rainmaker in the past and kill him.
I truly enjoyed this movie, it was absolutely much better than I had expected, and it makes you think more than the average movie. The story is clever and it works. You see influences of both Back to The Future and The Terminator in the story, as well as to Carrie and X-Men (with the concept of telekinesis), but it all fits well into the story.
I would highly recommend this movie. However, it´s not a movie for kids, due to violence (and for sensitive Americans, some nudity).
Lately I have been more active in the IBM DeveloperWorks forums, as well as on StackOverflow, trying to help people with development problems. As I am just myself starting with Xpages, I been staying in the forums for "classic" Notes development.
I have noticed a trend, based on the postings. It seems like there is a substantial number of new developers who are not very familiar with Notes/Domino development. They sometimes think Domino works like a relational database.
There are then several who are posting about very simple things, that can easily be found in the online help, or by looking at the properties for an element. Like how to extend the last column in a view to use all available space.
There was even one user asking about how to duplicate a specific @Formula in Lotusscript, when the help file got a cross reference to the class and method to use…
There are others who does not seem to even understand the basics, either when it comes to programming in general or specifically of Notes/Domino.
Some of them don't understand data types. They declare a variable as integer, then make a calculation that results in a value of say 3.5, and is then wondering why the result is 4.
Others don't understand the difference between strings and variables, they are surprised when @SetField("myField"; "myField + 1") does not give them the expected result (the value in the field ‘myField’ increased by one).
On StackOverflow it is possible to see what other areas the user posted in. Some of the users seems to have a background in Java, SQL, .NET or other platforms. My guess is that they been thrown into a Notes projekt after their company took on a new development project, with the hope that they could learn it quickly. I think this could be dangerous, from some of the code I have seen, the lack of experience and understanding of the Notes/Domino platform will cause sub-standard or slow code, which of course will make executives think that Notes is a bad development platform. After all, if the expensive consulting company (or the off-shore based development house with all developers being at least Ph.D.) can't write fast and good code, the platform must be at fault, right?
Another thing I noticed over the last year or so is that in the Notes-related groups on LinkedIn, there has been a number of requests for the answers to the IBM certification tests. They have originated from both some big consulting companies and from within IBM. None of them were from the US (or Europe, if I remember correctly), but from countries more traditionally associated with outsourced or "off-shore" development. My guess is that the companies want their developers to be certified on paper, as they can either charge higher rates, or pass themselves off as being “experts” on the platform.
A number of the questions in the DeveloperWorks forums were posted under names that often are associated with the same countries/regions.
What I think we are seeing is the result of American and (in some part) European companies using cheaper off-shore development companies in order to save money. What they don't think of is that, unless the developers has a good knowledge of the product, that a local developer with many years of experience will create the same or better result in a much shorter time. So even at a higher hourly rate, the end result will be less expensive as well as better.
I want to make it clear that I don't think all developers in the countries typically associated with off-shoring (India, China, Russia, the Baltic states, Brazil, etc) are bad programmers. I know very competent developers from several of those countries, and I know some not-so-good developers in Europe and North America.
What I am afraid of is that off-shore development companies takes on Notes-projects, expecting (or hoping) their staff will quickly learn the product/platform and quickly develop the requested solution. In the process they are making Notes look bad as they don't understand the platform.
At the same time, the companies that is purchasing the solution are just looking at the hourly rate, and perhaps an initial estimate of how quick and inexpensive (due to low hourly rates) the project is promised to be completed. In the long run, I fear that Notes/Domino as a platform will suffer because of this.
The project management triangle is still true:
You are given the options of Fast, Good and Cheap, and told to pick any two. Here Fast refers to the time required to deliver the product, Good is the quality of the final product, and Cheap refers to the total cost of designing and building the product. This triangle reflects the fact that the three properties of a project are interrelated, and it is not possible to optimize all three – one will always suffer. In other words you have three options:
Design something quickly and to a high standard, but then it will not be cheap.
Design something quickly and cheaply, but it will not be of high quality.
Design something with high quality and cheaply, but it will take a long time.
Of course, an experienced Notes/Domino developer can make the rule somewhat invalid, but it requires extensive experience. :-)
I don’t have a good solution. Perhaps companies thinking about outsourcing development need to be more diligent at selecting developers, requesting details about their previous experience, etc. Perhaps they need to ask more questions, including how many years of Notes/Domino experience the developers have. Personally, I would not suggest hiring a consulting company who haven’t had a presence at Lotusphere or at least had some of their developers speak there or at any of the LUG-conferences around the world. Many of the best Notes developers also got blogs where they post code and/or information, I would require a link to some blogs as well, so I could judge the quality of their code.
Neil Armstrong. The first man on the moon. Speaker at Lotusphere 2007 (where I took the picture above). Self-proclaimed geek.
I always loved reading about space growing up, and I read everything from sci-fi to real stories. One of my favorites was Carrying the Fire: An Astronauts Journey by Michael Collins (the third Apollo 11 astronaut), which I read in Swedish translation (as I was just 7 or 8 years old at the time).
So when Neil Armstrong stepped up on stage at the 2007 Lotusphere Opening General Session, that was the coolest speaker ever. And he was not just another celebrity, he was interesting and funny. My favorite quote was this (as far as I rememeber):
The scientists came up with an experiment to measure the distance from Earth to the moon, using a laser. But in order to do that, they needed a mirror placed on the lunar surface. I was the service technician tasked to put the mirror there.
Best speaker ever, and with Lotusphere being renamed to Connect, he will keep that title forever.
Last Thursday I got the Samsung Galaxy S3 I pre-ordered back in the beginning of June, and I have now been playing with it for a few days. There are of course other reviews (mainly of the international version) and overviews of the phone, so I will not list all the features and functions here.
As I am in the US, I received the North American version. It differs from the international version in that it has a dual-core Snapdragon S4 processor and 2GB system memory, instead of the Samsung’s own processor Exynos 4 Quad and 1 GB memory. This is due to the latter processor not supporting the North American LTE networks.
With this phone I am also moving from the Blackberry platform to Android. I have been looking forward to getting a nice big screen and a more powerful phone, but at the same time my biggest fear was the on-screen keyboard. The times when I have been using an iPhone or played with older Android phones in the store, I did not feel like I would be able to type as fast as with the Blackberry’s excellent physical keyboard.
I am coming from the Blackberry Bold 9700, with OS 5. The phone is about 2 years old, and originally came with OS 4. After I upgraded, the phone became more and more sluggish, and I constantly ran out of memory, in certain applications as well as when browsing the web. The GPS started taking longer and longer to get a fix, it could take me 2-3 minutes (if it even got the position) if I was indoors. The screen on the blackberry is also tiny compared with today’s phones, even if it was a very good screen when it came out.
So it was about time for me to get something more modern.
I was very pleasantly surprised with the keyboard on the Samsung Galaxy S3. As soon as I started typing, the correct text came out. The predictive text works very well, as long as I use English. I know there are other keyboards (like Swiftkey 3 that Mitch Cohen blogged about last week) where I can set different languages, so that is not a big deal right now.
The 4.8 inch Super AMOLED screen is just gorgeous, and features a resolution of 720×1280 pixels. The internal memory in my phone is 16GB (32GB and 64GB models are also available or coming soon). The memory can be expanded using microSD cards up to 64GB, and in some markets customers get a free 50GB DropBox account. My carrier, AT&T, opted out of this promotion. I already use DropBox, SugarSync, SkyDrive and Google Drive, so after downloading clients for those services, I can now easily transfer my pictures to my cloud storage of choice.
Just like on the Blackberry, and most other smart phones, the Galaxy S3 has several screens where I can place widgets, icons for applications, and folders containing additional icons. This way it is easy to organize all my apps. On the Blackberry I also used folders, but the lack of available memory caused me to eventually remove most apps.
The default setup came with a number of widgets, but I removed most of them from the screens and opted to just use icons. The lock screen shows the date and time, the current weather, and four icons for applications you want instant access too. To unlock, you swipe your finger over the screen, or swipe any of the four icons to launch that particular application.
I have already modified my phone by adding a custom wall paper, and as I mentioned above, I have organized the icons and widgets the way I want them. To the left you can see a folder open, showing the four applications located in it, in this case IBM Lotus Traveler.
I currently have four screens of icons, of the seven I can have. The first one, the "home screen, is where you end up after unlocking the phone on the lock screen. At the bottom you have five icons of the most frequently used functions, they stay on ever page. The the top of the screen is a notification area, with small icons indication new mail, text messages, twitter messages, etc. It also shows the status for network/wireless connection, battery status, as well as time.
As I mentioned, the keyboard is very impressive, and it exceeded my expectations. I had assumed that I would make a lot of typos, but the predictive text works very well. Or perhaps it is me being too predictable… But the result is that I have very few errors when I type. There are a few small issues, mainly how question marks and similar characters works and that there is no support for Swedish. But as I plan to evaluate a couple of other keyboards, that is not anything that bothers me.
As you can see to the left, when I start typing, suggestions show up above the keyboard. In most cases the suggestion is correct, but in case you want exactly what you typed, the option furthest to the left is what you entered.
You can also see the speech recognition icon to the left of the space bar. I have not used it very much. Speech recognition is of course available everywhere you would use a keyboard, but also on other places, like the S Note application. I have not had time to test the S-Voice yet, nor the face recognition unlocking of the phone or a few of the other advanced functions that is available in this phone.
But I did use the phone to call with. The sound quality is excellent, much better than on my Blackberry. From what I read online, it has active noise cancelling.
I also tested the web browser. As opposed to the Blackberry, it actually load every page I tested.
The browser is fast (especially on wifi or 4G LTE) and seem to render all pages I tested perfectly. However, I created some bookmarks, and a few hours later they were gone. I am not sure what I did, but now the bookmarks seem to stay. The browser support Flash, of course.
Talking about speed, I live and work in the Dallas-Ft Worth area, where AT&T have their 4G LTE network available. And it is fast, as you can see to the left.
The one issue I see with the phone is the battery. Despite having a 2100 mAh capacity, it usually lasts only to about 3pm. However, I been using the phon
e extensively, and I may need to tweak some setting. I have no power saving settings turned on, and usually run either wifi or bluetooth. Since I have 4G coverage, that also uses more battery. So one of my first purchases was a portable charger…
So the summary is that this is an amazing phone, and that my worry that the keyboard would annoy me was not an issue. I am very happy with the phone, just wishing the battery lasted a little bit longer.
In a blog entry from 06/23/2010, Charles Carreon (the lawyer who is suing The Oatmeal), posts about the outcome of the case Viacom vs. Google. Youtube, owned by Google, allowed their users to upload copyrighted material, and they then benefited financially from this through the sale of ads on the site. Exactly the same activity that his client FunnyJunk engages in.
As that blog entry in retrospect is somewhat embarrassing for Mr Carreon, he took that down. But since the internet never forgets, Google still got the page cached. Some interesting quotes:
If Google can generate ad revenue by taking in every kind of content without distinction, and make money on the infringing attractions, then Google can “work the float,” and always have enough infringing content to keep its blood pressure up at the expense of copyright holders. The only way that content owners can act proactively is by implementing digital “fingerinting technology” through the “Claim Your Content” system that Google uses as its only screening mechanism. Fingerprinting your content is not, however, cheap.
…
Please don’t take me for a copyright hawk, but this seems like a ruling that benefits a company that has made a habit of turning other people’s work into their payday, and is being encouraged to keep on doing it.
Here is an image of the page as well, as retrieved from Google this morning:
Click image for larger/high resolution version. Source: Google cache
Disclaimer: The blog entry is reproduced under “fair use”.
This last week we have seen two high profile examples of how you can screw up and make a total idiot of yourself on the internet. With social networks like twitter and Facebook, news spread quickly, and if it is perceived that there is something unfair going on, expect furious people to share it. When you or I, with perhaps a couple of hundred Facebook friends and twitter followers, post about it, it will still spread, but slowly. But when people like Jamie Oliver (2.5 million followers) or Neil Gaiman (1.7 million followers) tweet about it, things start spreading like wild fire.
The first example is The Case of The Thief Suing His Victim. Most of you are probably familiar with the online cartoon The Oatmeal. Matthew Inman, the guy behind all the funny cartoons, complained a year ago that a website called FunnyJunk was full of his drawings. FunnyJunk allow their users to post material (from a quick glance it looks like a large part of the contents is copyrighted material), and then when complaints are sent to them just blame the users, while cashing the checks for all the advertising on the site. Matthew blogged about FunnyJunk doing this about a year ago, and described their business model:
Here’s how FunnyJunk.com’s business operates:
1.Gather funny pictures from around the internet
2.Host them on FunnyJunk.com
3.Slather them in advertising
4.If someone claims copyright infringement, throw your hands up in the air and exclaim "It was our users who uploaded your photos! We had nothing to do with it! We’re innocent!"
5.Cash six figure advertising checks from other artist’s stolen material
Last week, Matthew was served with papers, demanding him to pay FunnyJunk $20,000 or be sued. FunnyJunk had hired Charles Carreon as their lawyer, who wrote that letter.
Matthew responded publicly here: http://theoatmeal.com/blog/funnyjunk_letter
I highly suggest reading the whole thing. It is extremely amusing.
So Matthew sets up a fundraiser. Not to raise money to pay off FunnyJunk, but to split even between the National Wildlife Federation and the American Cancer Society. He raised the $20,000. In 64 minutes! The amount collected by "Operation BearLove Good. Cancer Bad." is currently at $169,000. However, the lawyer, Charles Carreon, is trying to shut down the fund raiser, according to MSNBC. He is also complaining that he was not expecting an outpour of hate and people being upset at him, or having his mom accused trying to seduce a Kodiak bear (the drawing is supposed to be of the mom of the FunnyJunk admin/owner, not the lawyer, by the way). Very strange that someone who market himself as a cyber attorney is so clueless to how the internet works. He should lookup the Streisand effect, as well.
Even other lawyers chime in. The law-blog PopeHat.com uses some strong words:
So, The Oatmeal tried to turn this into something good ?something that would benefit wildlife protection and cancer research ?and Charles Carreon had a snit and tried to shut it down because it was embarrassing to him and his client?
Fuck him. He’s vermin. He’s not forgivable. Let any good he has ever done be wiped out. Let the name "Charles Carreon" be synonymous with petulant, amoral censorious douchebaggery.
Another lawyer, who supposedly knows Charles Carreon, is also quoted on the same page:
Despite my earlier charitable comments, I can not find any words to defend trying to shut the fundraiser down. I can’t even gin up a minor benefit of the doubt on that one. I can see an ill-considered demand as a mistake in judgment while hoping to gain an advantage for your client. But taking a shot at the fundraiser would not do that ?it would just be lashing out to hurt bears and cancer patients? Holy fucking shitballs inside a burning biplane careening toward the Statue of Liberty, Captain! I hope that the reporter merely got the story wrong, because if not, that’s more fucked up than a rhino raping a chinchilla while dressed up in unicorns’ undergarments.
It will be interesting to see the outcome of this. The twitterverse seems to have the consensus that Charles Carreon just committed career suicide.
The second example is The Case of NeverSeconds. A nine year old girl, Martha Payne (who blog under the name VEG), started a blog called NeverSeconds, where she posted pictures of her school lunches, as well as described them (contents, taste, etc). This is a great blog!
Picture by Martha Payne, from this blog entry.
The blog went viral recently, and children in other countries are sending her pictures of their lunches. Martha is also raising money for Mary´s Meals, a charity trying to feed poor children. UK newspapers started writing stories about the blog and how the schools should serve healthier (and bigger) meals for the kids.
However, on Thursday Martha posted a message titled "Goodbye.":
This morning in maths I got taken out of class by my head teacher and taken to her office. I was told that I could not take any more photos of my school dinners because of a headline in a newspaper today.
I only write my blog not newspapers and I am sad I am no longer allowed to take photos. I will miss sharing and rating my school dinners and I´ll miss seeing the dinners you send me too. I don´t think I will be able to finish raising enough money for a kitchen for Mary´s Meals either.
Goodbye,
VEG
The school board decided to stop Martha from taking pictures. Supposedly one of the newspapers who picked up the story about her blog had called for the lunch ladies to be fired. So it was not even something Martha did.
This story was picked up by UK and international news outlets, and celebrities like Jamie Oliver and Neil Gaiman posted on twitter in support of Martha. Her charity went from ,000 to (currently) 7,000strike> 8.000 (and it keeps going up) in a few days! Donate you too.
After a media- and twitter frenzy, and after the members of the
school board of Argyll and Bute were contacted by the education secretary of Scotland, the ban was lifted today. The school board first posted this statement, still trying to shift blame to Martha. They then retracted that and posted another statement. I suspect that the first statement is how the council really felt, that government officials should not be allowed to be criticized. They were probably forced by higher-ups and more outrage to withdraw the first statement and replace it with another one.
This is a great example on how NOT to act when criticized. Basically a hug PR fiasco.
So there you have it, two great examples of a website/lawyer and a group of politicians who dug themselves a hole, and then kept digging. I have a feeling that that school board will be gone at the next election. And that the FunnyJunk lawsuit will be thrown out of court quickly, if it even get there. By the way, Matthew Inman have retained Venkat Balasubramani to handle the case:
I have discovered that The Oatmeal is represented by none other than Venkat Balasubramani, who will lay a motherfucking smackdown if you make him. While The Oatmeal´s response is funnier, Venkat brings his A-Game here.
Let´s bring out the popcorn! But first, go and send some money to the bears/to stop cancer and to feed the children.
Update: Martha is back! Monday she will take a new picture and post. Also, her fund raiser is now up to 2,300″…”
Today I needed to use regular expressions (a.k.a. regexp) in a Lotus Notes application. I just wanted to check if the user entered a claim number (in the format “nnXXXXXnnnnn”, e.g. 12RICTX12345) in a field. A quick online search found a blog entry with some code using the VBScript object available in Windows, and I adapted it for my application.
Just in case someone need this, I am posting the code below. I am not taking credit for the code, I found it on Giles Hinton´s blog and just adapted it a little bit.
I also found information about using LS2J and Java to handle regular expression in Notes, which should be platform independent, not restricted to just Windows. Since all our users are on Windows (either directly or through Citrix), I could use the quick method below. But I would probably use the script library posted on OpenNTF for more serious code.
Dim ws As New NotesUIWorkspace Dim uidoc As NotesUIDocument Dim regex As Variant Dim pattern As String Dim result As String Dim match As Boolean '*** Define pattern and get text value to check for match pattern = |b([0-9]{2}[a-zA-Z]{5}[0-9]{5})b| Set uidoc = ws.CurrentDocument subject = uidoc.FieldGetText("ShortDescription") '*** Create RegExp object Set regex = CreateObject("VBScript.Regexp") regex.Global = True regex.IgnoreCase = True regex.Pattern = pattern '*** Test for match of pattern in text match = regex.Test(subject) If match = True Then Msgbox "Claim number was found in the field." End If
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 have been any Morder orcs, but Isengard orcs. There is two sets of Uruk-hai armor (complete with the white hand of Sauroman), a crane to lift material to melt for the forge, etc.
So what is the verdict? As a Lord of the Rings fan (both the books and the movies by Peter Jackson), I am very happy with the LEGO kits this far. The quality is good, the instructions are very clear (recently I have seen some instructions where it was easy to miss a piece of pick the wrong shade of gray) and the detailing is amazing.
I still have two more kits to build that I already purchased, and I have to get the last kit (Battle of Helms Deep). I will report on them later.