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.