Thursday, March 18, 2010

Selenium Exception: Unable to Delete File (parent.lock)

Problem: When using FireFox for Selenium tests, Selenium RC is throwing exceptions with the error message “Selenium.SeleniumException: Failed to start new browser session: Unable to delete file” with a reference to a “parent.lock” file in your temp folder. Cleaning up FireFox profiles doesn’t help.

Solution: You may be using an older version of the selenium-server.jar. Go grab the latest download of Selenium RC. At least that’s what fixed it for us…

Friday, March 12, 2010

Getting an Assembly From the GAC

Windows Explorer lets you browse the Global Assembly Cache (GAC) and drop strongly-named assemblies in if you’ve the proper permissions. What you can’t do is pull things out of the GAC using Explorer. Explorer hides some abstractions of the GAC from you, preventing you from pulling assemblies out.

I had the need to validate that an assembly in the GAC was indeed the version I expected; however, once a file’s in the GAC you can’t just drag it out using Explorer. (I couldn’t rely on the Version number shown in Explorer – it’s a DLL related to some SharePoint work and the pain of dealing with versioned assemblies in SharePoint is a rant I’ll save you from. Today.)

You can get around this with a quick bit of command-line fu, though. Actually, it’s just copy, so it’s not even fu.

Using an admin account, open a command prompt and change to the %SYSTEMROOT%\assembly folder. There are a number of folders under here:

C:\Windows\assembly>dir /b
GAC
GAC_32
GAC_64
GAC_MSIL
NativeImages_v2.0.50727_32
NativeImages_v2.0.50727_64
temp
tmp



Use dir /s to find the assembly you’re looking for. (Line breaks inserted)



C:\Windows\assembly>dir TelligentEvolution.Wss.Global.dll /s /b
C:\Windows\assembly\GAC_MSIL\TelligentEvolution.Wss.Global
\4.1.31029.3047__454c7a96e9526647\TelligentEvolution.Wss.Global.dll



Now you’ve got the full path to the assembly. Use copy to get it where you want it.



C:\Windows\assembly>copy GAC_MSIL\TelligentEvolution.Wss.Global
\4.1.31029.3047__454c7a96e9526647\TelligentEvolution.Wss.Global.dll
d:\temp
1 file(s) copied.



Poof. Now I can get at the file with Reflector for a bit of inspection.

Friday, February 12, 2010

Software Engineering 101 in Nashville on 2/27

Jon Kruger, Leon Gersing, and I are repeating our highly successful SWE 101 event (event wrap up blogged here) in Nashville, TN, on 2/27. Registration’s already open, so please join us if you’re in the area.

Oh, wait! You can actually attend via a Live Webcast if you’re not in the area! Register for that here.

The event’s schedule’s on the registration pages, but it will follow the same format as the one in Columbus: the morning focuses on laying out fundamentals, and the afternoon is all hands-on test driven development putting the morning’s content to practical use.

Come prepared to learn, interact, pair up, and cut some code with other geeks. It’s how we roll.

Thursday, February 11, 2010

Case Studies on Benefits of TDD

I’m a believer in test driven development. For many reasons. I don’t do it enough myself, the people I’m around don’t do it enough, the people I talk to don’t do it enough. For many reasons.

One commonly cited reason is a lack of evidence about TDD’s benefits. I’ve always found that a bogus argument, because I think it’s fairly easy to look to specific metrics around code complexity and bugs in a before/after environment.

Without further ado, here are some links pointing to various studies on TDD. Note these links are to TDD. I didn’t even go down the route of “show me stuff that backs up the benefits of unit testing, not just TDD.”

Using Bing I Googled this search phrase: “test driven development studies” and got these great hits:

From Biblio, an entire page of studies.

In InfoQ, an article on a study from folks at Microsoft and IBM. The InfoQ article links to the Empirical Software Engineering Journal’s article which costs $34 to read. Evil, greedy, profit-grubbing Microsoft hosts the article here for free. A comment in the InfoQ article points out some great contrarian questions which you need to ask yourself about TDD.

There’s also a video on Channel 9 interviewing one of the study’s authors. (I haven’t watched it. Yet.)

An interesting paper summarizing several other studies in industrial, semi-industrial, and academic environments. Benefits in the latter two environments were not as apparent, particularly in the academic. I wonder if some the low benefit in the academic environment is due to a lack of real-world experience both in the students and their instructors.

Does Test Driven Development Really Improve Software Design Quality an awesome article published in IEEE Software back in March/April 2008. Read closely the sections on misconceptions and cons. Chase down some of the other referenced reading there, too.

Hopefully you’ll find these articles and links a good starting point for your own reading. Use them wisely when trying to make the case for selling TDD (or even just unit testing, period) to your teams, management, and customers. Keep in mind these critical points:

  • Be honest. Unit testing and TDD aren’t silver bullets. Crap code driven by crap tests driven by crap requirements is still a pile of crap.
  • Be honest. Your perceived productivity will drop. You’ll be knocking out less features on any given iteration/cycle/release.
  • Be honest. You’ll suffer additional productivity losses as you learn how to do testing, preferably in TDD fashion.
  • Be honest. There will be culture and skills issues with your team, your management, your customer, and you.
  • Be honest. Testing and TDD is often more about long-term gains than short term. You’re trading feature velocity for overall quality and maintainability.
  • Be positive. The gains you’ll realize from moving to TDD are significant: reliability, quality, maintainability.
  • Be positive. The speed at which you’ll realize those gains will greatly improve as you move forward and get up over the learning curve.
  • Be positive. There’s a growing mountain of solid study-based evidence around the benefits of unit testing, particularly TDD. I emphasized “evidence” because too often we geeks get so fired up about things that we are passionate about that we ignore arguments based on facts and evidence.
  • Be positive. There are specific metrics you can use to show the gains: complexity metrics (NDepend, FTW!), code coverage, decreasing bug counts, fewer escaped-to-customer bugs, increased velocity around future maintenance and expansion.

Now go forth and do battle! “Sancho, my armor!”

Friday, January 22, 2010

Making DevExpress & ReSharper Play Nicely

I use both DevExpress’s IDETools and JetBrains ReSharper on my dev boxes. Why? Because I’m a tool whore. That and I like different pieces of both of them. DevExpress gives me awesome visualization, and R# gives me awesome other stuff.

Here’s my quick steps to making them play nicely together in VS 2008:

  1. Install DevExpress tools first
  2. Install ReSharper
  3. Start VS, fill out license info as you’re prompted
  4. Tell ReSharper to use R#/IntelliJ key mappings
  5. Disable DevExpress options I don’t like
    1. DevExpress | Options
    2. Set Level to Expert (lower left corner of dialog)
    3. Editor | Auto Complete | Intellassist | Setup | clear Enabled checkbox (I like R# completion better)
    4. Editor | Auto Complete | Intellassist |Parens & Brackets | clear both options for Smart Parens and Smart Brackets (I’ve always had grief with these conflicting, so I shut ‘em off)
    5. Editor | Clipboard | Smart Cut(Copy) | clear Enabled (Plain ol’ VS copy/cut/paste works for me)
    6. IDE | Shortcuts | search for Ctrl-B (PasteReplaceWord) | clear Enabled (I use Ctrl-B in R# to go to definition)
    7. IDE | Shortcuts | search for Ctrl-Alt-F (QuickFileNav modal) | clear Enabled (I use this shortcut in R# for formatting code. R# gives me Crtl-N and Ctrl-Shift-N for type/file nav)
  6. Force ReSharper once more to use its shortcuts. ReSharper | Options | General | Visual Studio Integration | Restore ReSharper keyboard shortcuts | ReSharper 2.0 or IntelliJ IDEA | Apply

These are MY preferences, but it’s what works for me.

Thursday, January 21, 2010

Flag Parameters are Evil! (Or at least unclear)

The more parameters you have in a method call, the more chances you have to screw things up. Moreover, method signatures with boolean parameters (flags) add in clarity problems, too – even if the input parameter is well-named.

Instead of exposing a non-private method with a flag, make that method private and instead expose two well-named, explicit methods which are simple facades over the newly private method.

Instead of

protected T CreateRestServiceInstance<T>(bool impersonateEnabled)


use



protected T CreateRestServiceInstanceAsServiceUser<T>()
{
return CreateRestServiceInstance<T>(false);
}

protected T CreateRestServiceInstanceWithImpersonation<T>()
{
return CreateRestServiceInstance<T>(true);
}

private T CreateRestServiceInstance<T>(bool impersonateEnabled)
{
//wonderful shiny stuff here
}



You’re making your class’s API explicit and clear, and you’re cutting the risk of someone goofing up and missing something important – like invoking a REST endpoint as a service account instead of impersonating the user.



Not that I’ve ever done this myself, mind you…

Saturday, January 16, 2010

I Am Not CodeMash

Every year I get lots of people thanking me for putting on CodeMash. I get comments about how the conference has changed their thinking and gotten them fired up to go do great things back at work. I’m humbled and flattered, but I’m not the force behind the conference. I’m not CodeMash.

Brian Prince puts in 300 – 400 hours a year handling registration and overseeing our web efforts. Brian is CodeMash.

Jason Follas puts in around 200 hours dealing with sponsors, t-shirts, schedules, and hundreds of other little tasks I never hear about but somehow magically get done. Jason Follas is CodeMash.

Jason Gilmore puts in nearly 200 hours overseeing the 500 session submissions we get for 60-some-odd session slots, plus he handles all the schedule planning and timeslotting, and he handles all the speaker coordination. Jason Gilmore is CodeMash.

Our content selection committee of Dianne Marsh, Joe O’Brien, Jay Wren, Sarah Dutkiewicz, and David Stanek had the tremendously difficult task of culling through those 500+ submissions to pick out the best possible lineup for the conference. CodeMash has lots of Great Stuff to do, but it’s all based on the amazing content. Dianne, Joe, Jay, Sarah, and David are CodeMash.

Darrell Hawley and Mike Woelmer took on tremendous responsibilities for owning the coordination for the Enter The Haggis concert and all our VIP travel coordination, respectively. If you think that’s an easy task please go kick yourself in the teeth. Moreover, they did that at a point when I was in an awful spot with work and life and could not have handled either task at all. Darrell and Mike are CodeMash.

Our 58 speakers and 3 keynoters delivered the amazing presentations that make CodeMash really shine above many other conferences, regardless of size. Those folks are CodeMash.

Scott Zischerk, Chris Woodruff, Mike Wood, and Steve Andrews are always pitching in to lend a hand wherever it’s needed, regardless of whether it’s schlepping trash, handing out tshirts, or manning the registration booth. Scott, Chris, Mike, and Steve are all CodeMash.

Finally, look at the attendees who show up and get outside their comfort zone. Look at those attendees talking in open spaces during the conference and interacting with folks they’d never get a chance to otherwise. Look at the folks pairing up in the Coding Dojo and polishing up their skills. Look at the folks in Leon Gersing’s PreCompiler TDD Workshop session who filled out retrospective cards with blurbs like “Loved a practical workshop with Agile!” or “Never paired before, but learned a lot!” or “Didn’t know anything about Rails before today, but loved the experience.” Those folks are CodeMash.

I’m not CodeMash. YOU are CodeMash. I’m just lucky to be a part of it. Thanks!

Now go do something with what you learned. Me? I’m taking a nap.