Thursday, May 12, 2011

XQuery Katas

After having several MarkLogic projects back-to-back, I haven't had a new one in far too long. So, to practice my XQuery in the hopes of having a new one soon, I've started a collection of XQuery katas.

The intent of these is less TDD and more brushing up on XQuery, but I'm also interested in testing my functions. To that end you'll see I have my tests built using:
  1. Visual Studio
  2. NUnit
  3. Saxon HE
Meager, but it suits my current needs.

My first kata is up now on BitBucket and I've gotten some constructive feedback from the xquery-talk mailing list. I hope to add more over the next few weeks.

Getting Capabilities from WURFL in ASP.NET

This is one of those things that took me a little too much time to find the first time around.

I'm using WURFL with 51Degrees for mobile device detection in an ASP.NET MVC application. I needed to also detect whether the device using the app is a tablet or not. WUFL has the "is_tablet" capability defined, but this is not a default property on the Browser object.

So how do you get at the value for the current request? It's pretty simple once you see it:

Request.Browser["is_tablet"]

Wednesday, March 16, 2011

Tequila

I'm on a quest for a tequila that is as smooth to drink as Grand Marnier.
  1. paQuí Silvera : Surprisingly, this is a bit easier to drink than Herradura Añejo. It simply has a little less bite. I expected that I would like an añejo more.

  2. Herradura Añejo : It's not quite smooth sipping, but very good with a small piece of ice.

  3. Patrón Silver : Not sure what all the fuss is about here. They're clearly brilliant marketers.

  4. Cabo Wabo Reposado : Essentially donkey urine with artificial sweeteners. I can't believe I actually paid money for this. I couldn't choke down the last few ounces even in a mixed drink so I poured it down the drain, an act I would normally consider heresy.

Launchy, Remote Desktop, Dual Monitors, and Windows 7

I've come to love Launchy -- to the point where I get irritated when it's not installed on a machine I might be working on temporarily.

Unfortunately, when I setup my new machine, I suddenly could not trigger Launchy while using my preferred remote desktop application, visionapp Remote Desktop. I'm not sure if it was my new dual-monitor configuration or Windows 7, but every time I hit Alt+Space it would trigger Launchy on my machine no matter what I did. This was not a problem on XP with a single monitor.

The work-around I found was to change the hotkey combination on the remote machine. I simply changed it to Ctrl+Alt+Space and it worked perfectly! Wish I thought of that sooner!

Wednesday, November 24, 2010

Writing Unit Tests Makes Me Feel Stupid

Writing unit tests makes me feel stupid.

Allow me to explain.

I'm not talking about full-blown TDD, but simply about a beginner trying to write some tests in order to make sure code is working as expected in as many cases as possible. What I almost invariably run up against is my own questionable design choices that usually boil down to three issues: lots of dependencies, needing non-trivial data for a meaningful test, or needing a full ASP.NET web request for a meaningful test.

Sure, some classes are small and simple and will have clear tests supporting them. A few more classes will interact with those first ones clearly and cleanly, too. That'll be about ½ of 1% of my total system. While trying to write tests for the rest of the code I'll be mumbling
"How the heck am I going to test that?"

"Ugh. I need to inject that into that into that just to test one method."

"Why would I write it like this? Was I in that much of a rush?"
The more I think about testing my own code on current projects, the more I understand the usefulness of TDD and that the goal is not simply tests but an easily consumable, testable design. I've read Pragmatic Unit Testing for a baseline. Hopefully The Art of Unit Testing and Clean Code will help me avoid painting myself into these corners in the future. In the meantime, I've been watching James Shore's Let's Play TDD series, which is really cool because you're essentially looking over his shoulder as he works on a small app.

I've started to wonder if other people feel the same way and if they avoid testing because of it or if they realize that it's a learning opportunity.