logo

It's Always The Simple Tips That Are Best

The discussion that followed yesterday's post soon turned to the subject of performance. While this was interesting it wasn't what I was thinking about when I passed on the tip. Rather I was thinking about ease of coding. The tips I like best aren't just those that make my applications appear faster but also those that make my code less complicated and quicker to write.

That's why I got all excited yesterday when I read Tommy's brilliant tip on Simplifying Evaluate. So much so that I immediately commented on it, dragged the link to my RSS "news bin" and made a mental note to blog about it today. Tips like this deserve as large an audience as possible.

Tommy's tip lets you replace this code chunk:

Dim tmpVar as Variant
Dim commonUsername As String
tmpVar = Evaluate( |@Name( [CN] ; @UserName )| )
commonUsername = tmpVar(0)

With this one:

Dim commonUsername As String
commonUsername = Implode(Evaluate(|@Name([CN];@UserName)|))

This to be used in cases where the result of the Evaluate is only ever a single value. Ok, so it's only two lines shorter, but it's still easier and just feels cleaner. I've always disliked dimming variants just so I can find the result of an Evaluate call. Something just seems not quite right about it. No need to any more. Thanks Tommy.

If you don't read Tommy's blog then you really should start. There's always something useful to read and he's always willing to put in the time and effort to deliver. One of my favourite Notes-based blogs at the moment.

Comments

    • avatar
    • Patrick Ryan
    • Tue 2 Oct 2007 05:50 AM

    I love his blog title :-)

    • avatar
    • Kerr
    • Tue 2 Oct 2007 06:42 AM

    Yeah, sorry Jake, it's always easy to get side tracked by performance. For anyone not aware of stampAll, it's a great tip. I'm forever forgetting about features like that.

    Another great tip here. When I'm forced into doing LotusScript I always find myself beating my head against the wall dealing with it's arcane rules.

    Give me Java any day.

    String foo=(String)session.evaluate("@Name( [CN] ; @UserName )").get(0);

    I'll apologise now for any ensuing religious war. ;)

  1. I would be so happy if we could just use the current version of Java :-)

    However, Notes 8 is not in my company's future, probably until 8.5 comes out since we are retiring our Notes clients and going to a 100% web based strategy for our intranet in concert with switching to Exchange for mail.

  2. You can even make it shorter using Join instead of Implode (4 letters versus 7) :-)

  3. Thank you for the very nice words :)

    After I discovered the one liner, I've also done stuff like:

    If Implode( Evaluate( |@UserRoles = "[Editor]" | ) ) = 1 Then

    'dosomething

    End If

    • avatar
    • Thomas
    • Sat 13 Oct 2007 03:44 AM

    The bad thing of a local swedish blog is that my tips never seem to reach the global audience.

    I blogged about the advantages with implode last year and I have at huge list of examples at my site.

    I also made a Youtube vide on how to simplify evaluate statements. (in swedish)

    {Link}

    Thomas

    {Link}

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Tue 2 Oct 2007

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content