Archive for the 'Tools' Category

Which Productivity Tricks Have You Adopted Lately?

Every since I learned that the most important characteristic of people who become experts is that they continue to learn throughout their careers at the same pace they did when they were beginners, I have found it helpful to do regular mental inventories of new things I’ve recently learned as a way to keep myself honest.

Here are some of the productivity tips that I’ve picked up in the last 3-4 months that have worked out well and saved me quite a few wasted keystrokes and mouse movements:

  1. Launcher Program Parameters - In my recent post Friends Don’t Let Friends Use the Start Menu, I described my newfound addiction to SlickRun as a way to launch programs. Since then a few people have suggested that I try Launchy instead because it automatically detects programs without any keyword setup. I still intend to give it a fair chance, but I have to admit that so far I’ve been too distracted by experimenting with using SlickRun parameters so that I am not just opening a program but also accomplishing the first task or two that I normally would perform. For example, instead of just opening Firefox I now have different “magic words” configured to open one or more web sites at the same time. I also have different keywords set up for opening up each of my Visual Studio solutions as well as connecting to each of my different database servers with SQL Management Studio.
  2. UltraMon Window Switching Hotkey - I’ve been hooked on UltraMon as a way to quickly switch windows back and forth between monitors for a while, but I’ve only recently thought to set up a hotkey(there is a HotKey tab in the UltraMon properties window). Now I switch the active window to my other monitor by just hitting Ctl + Right Arrow Key.
  3. Adding NotePad2 to Context Menu - Life is too short to open random source files with Visual Studio. That’s why I prefer using Notepad2, which offers syntax highlighting but opens instantly. I recently ran across this blog entry that shows how to hack the registry so that this handy utility shows up in the context menu. Now when I want to open source files outside of Visual Studio, I simply right click on the file and choose NotePad2.
  4. Address Bar Hotkey (Alt-D) - I picked this tip from a recent Jeff Atwood post and have since used it about a thousand times a day since it works both with the browser and Windows Explorer.
  5. Lighter Weight ToDo List - Adding to the “ridding my life of tools that take too long to load” theme, I’ve recently stopped using Microsoft Word to track my To Do list and instead started using a lightweight utility that comes with SlickRun (Jot). Now when I need to jot down a task or thought, I hit Ctl-J and a little green window pops up within in milliseconds rather than the 3-6 seconds it takes Microsoft Word to load. It doesn’t sound like much, but it really adds up over the course of a day. Also, given my ADD tendencies, I have trained myself to immediately jot down random tasks or thoughts immediately as they occur to me or else I tend to lose track of them. However, if I can’t do this in one swift, fluent motion, then I lose all the momentum I had built up on my prior task so this is a big boost me personally in that respect.
  6. Unlocking Files with Unlocker - If I get impatient loading up Visual Studio and Microsoft Word, then you can imagine how reluctant I am to reboot my laptop or a development server. Rather than rebooting to solve a file locking related issue, I used to fumble around with Process Explorer in order to figure out which program or service needed to be shut down rather than rebooting like I’ve observed other people doing. Now that I have the Unlocker utility installed, all I do is right click on the locked file and select ‘Unlocker’. The utility displays a list of all the open file handles along with the option to simply unlock the file or else kill the locking process.
  7. Configuring VSS to use BeyondCompare for File Comparisons - Every piece of code gets reviewed where I work now, which means that version comparison becomes a pretty critical feature. God help us that we still haven’t managed to find the time to migrate to a real source control tool yet, but one saving grace is that we all have BeyondCompare2 configured as default comparison tool. The VSS comparison functionality just highlights the line that has changed, but BeyondCompare2 highlights the exact characters that have changed. This doesn’t sound like a big deal, but the savings in time and eye-strain add up quickly if your shop is strict about code reviews.

I picked up many of these tips by simply observing my co-workers or following suggestions I read in a blog posts. Other improvements came about as a result of trying to pay attention to any actions I did frequently that seemed to take more steps than they should and then creatively thinking about how to reduce the number of steps.

No matter how you end up picking up these kinds of tips, the trick is that you have to be willing to invest energy in changing your workflow habits.

Which tricks have you picked up recently?

Battling Password Chaos

Keeping track of my passwords has been a nagging problem for me for a long time, but I only recently got around to doing something about it.

I’m ashamed to admit it, but up until now I’ve relied on a few popular but extremely insecure strategies to manage my various online identities.

  1. Reusing passwords - The obvious danger here is that some script kiddie compromises a very insecure ‘mom and pop’ site that stores my password as plain text and then goes around to all the popular sites trying it out until he finds one that works. Even though I was foolish enough to take this risk for years, most sites have different password complexity rules. That meant that I still had to rely on several different userNames and passwords combinations, which made revisiting sites that I hadn’t been to in a while painful since I invariably had to try several times before hitting upon the right one.
  2. Forgot Password Email Feature - I don’t know about you, but I don’t normally access my yahoo email over SSL and many sites simply resend the password in plain text. This means that my password is visible to anyone with a strategically placed packet sniffer, like WireShark. It’s also annoying to have to wait for the email to be sent each time.
  3. Firefox Password Manager - I let Firefox remember passwords for me all the time and I recently discovered that this is hugely insecure. If you’ve never used the SIW (System Information for Windows) tool from gtopala.com, take 30 seconds to download it and then click on the secrets node under software. You will be greeted with all of your passwords in plain text from any site that you’ve allowed Firefox to remember for you. That means if anyone ever gets even momentary access to your computer, all of your online identities will be compromised. Not cool.
  4. Password protected Excel worksheet - Let’s face it. Microsoft Office security is a joke. I’ve tried this tool with file based dictionaries from this site on Excel 2003 documents and it has cracked the passwords almost instantly. I’ve tried this other tool with Office 2007 documents, which uses stronger encryption. It was pretty slow, but it eventually figured out the password as well.

Whether I’ve legitimately scared you or else you’re just sick of jumping through the “Forgot Password” hoops, I highly recommend trying KeePass. It is a open source password management tool that lets you store passwords securely and safely copy credentials into web forms.

KeePass lets you logon using a password/file combination for extra security and has several clipboard security measures built-in to prevent clipboard monitoring hacker tools from stealing the password while you’re pasting it into a website.

As far as encryption is concerned, the site boasts that even if you would use all computers in the world to attack one database, decrypting it would take longer than the age of the universe. That seems pretty secure to me…

If you’re still being lazy and insecure like I was, why not do something about it?

It only takes a few minutes to download and you will dramatically decrease your security related browsing frustrations as well as reduce your risk of identity theft.

.NET Framework Debugging 1, Reflector 0

Reflector has and will continue to be one of the coolest, most useful development tools around. However, when it comes to demystifying .NET framework classes, there is a new game in town.

Here’s a glimpse into what a method in the System.URI .NET framework class looks like using Reflector.

Not bad…but here is what it looks from inside the Visual Studio debugger after configuring it to use the newly available Microsoft symbol server.

Besides actually allowing you to see the control flow in action, manipulate input values, and replay edge case scenarios, this new approach lets you see all of the original developer comments. The ones I’ve looked at so far have tended to add real value to the code reading experience rather than just pointing out the obvious.

Also, since it is derived from the actual source code files rather than a reverse-engineered approximation, the code can serve as a valuable learning tool by showing real-world examples of best practices rather than the 2-3 line fluff usually found in documentation.

Well, ok…the code fragments above are screaming for some “Extract Method” refactorings, but in general I’m guessing the Framework has some instructive examples of how to program given the vast amount of effort and review that goes into the framework classes.

If you haven’t given it a try yet, the setup process to get this working is fairly easy. It simply involves installing a Visual Studio 2008 QFE and changing a couple of debugging configuration options (see Shawn Burke’s post). Within minutes, I was able to F11 into WebClient.DownloadString(). For some reason this just magically worked the first time, but the next day I had to right click on System.dll in the modules window and select “Load Symbols” in order to get it to work.

Below you can see in the Modules window how it shows that the symbols are loaded for System.dll and you can see in the call stack window that I am inside a framework method. If you look in the directory on your local machine that you configure as the symbols location, you’ll also be able to see the downloaded PDB file after you do this step.

Reflector will still hold an esteemed place in my developer toolbox when I need to peek inside all non-framework dll’s or verify the contents of a deployed dll, but I doubt I will use it anymore to spelunk framework dll’s (at least the ones whose symbols have been released).

Update: Although the setup was seamless on my Vista box at home, I haven’t been able to get the QFE to install on my Windows XP laptop yet. I don’t know if this is a common problem or if my machine has some unusual quirk due to the hundreds of utilities I install on it.

Vil: Dead as in Doornail?

I spent some time last week working with Vil, a free code analysis tool that can be used to locate potential quality issues and high risk areas in your code. While working on it, I learned all about various code metrics such as cyclomatic complexity, eCouplings, and LCOM (Lack of Cohesion in Methods) and experimented with setting appropriate thresholds for each.

I also incorporated all the required command line switches into our Nant script and even dusted off my XSLT skills in order to create a custom stylesheet to summarize the results and display them nicely on our main Cruise Control report. To my surprise several of the other developers at work seemed genuinely interested in the potential feedback we could get from this tool (people can only get so excited about cyclomatic complexity).

There was one major problem. All the fun I was having was restricted to one small dll. This is because Vil has a built-in limit so that a license key is required when you try to analyze a dll that has more than 100 types in it. The website indicates that all you need to do to attain this license is to send them an email. I did that. Twice. That was two weeks ago and I still haven’t heard anything back yet.

Vil is free, so one could argue that I am just getting what I paid for. I guess I figured that since Vil was incorporated into the WebDashboard for CruiseControl, it was established enough to be a safe bet. I was wrong. The last update on the website was two years ago and it was only a vague promise of a new version that would support the 2.0 framework. The new version never appeared and the current version seems to be from mid 2004.

I’m not even sure why the creator of Vil decided to include a built-in limit since the license to unlock it is supposedly still free. Perhaps he had some intention of eventually making it a commercial product or maybe he just wanted to keep statistics on larger customers. If it was an open source project and the source code were available, then I wouldn’t mind digging through the code to remove this restriction myself. But there is no source code to be found.

A Plea to the Project Owner: I understand there are plenty of good reasons to abandon a project that you weren’t making any money on. However, if you are calling it quits, could you please make one last altruistic gesture and either release the source code or else publish one last version without this restriction? It seems like a lot of work to have spent on an otherwise decent tool only to let it fall into oblivion because of this license issue.

Recommendation to Potential Vil Users: Don’t bother investigating this tool unless you already have one of the fabled golden license keys. I’m migrating back to NDepend instead. I’ve already worked with NDepend and think that it is a far better tool, but I gave Vil a try because it seemed like it would be a lot easier to integrate into Cruise Control due to the built-in support.

Request To CruiseControl Developers: Please remove Vil plugins and stylesheets from the next version of Cruise Control. It’s aggravating to spend time getting it to work only to later have to abandon it because it only works with trivially small projects.

OK, Rant complete. I feel better now.

Side Note: Apparently the phrase “Dead as a Doornail” is a very old expression and can even be found in a few of Shakespeare’s plays like Henry IV. Based on a quick google search, it appears that nobody really knows why doornails are any more dead than all the other inanimate objects (for example house nails). I saw a few weak guesses, but no explanations that were really compelling. I guess language is as uncontrollable and mysterious as the internet.

Are You Mocking My Code?

I’ve been playing around with mock objects using Rhino.Mocks for the last few months, but today was the first time that I had an unfettered coding win and became a true convert.
I was introduced to NUnit about five years ago from a co-worker (thanks Dewayne) and gradually became a true believer.

Unfortunately, I was a late-bloomer in the area of mocking, so by the time I finished my last big project I had left a suite of about 500 database driven tests that took almost 2 hours to run and were a maintenance nightmare. The vast majority of my unit testing efforts revolved around SQL initialization and cleanup scripts that massaged the database into just the state I needed for each tests case scenario.

Although this approach definitely made me a wizard when it came debugging data-related production issue quickly, it was too high of price to pay for the benefits I was receiving. Although I remember thinking in the beginning that this “realistic” approach to testing was much more valuable than the “fake” tests that didn’t hit the database, by the end of the process I was no longer so sure. I still believed in the value of unit testing, but I knew there had to be a better way of doing it.

During my stint as an architect, I read enough about mocking to know that it was a good idea in theory, but of course I had little opportunity to put that theory to the test. Now that I am a code monkey again, I can say with certainty that mocking is an absolutely essential aspect of Test Driven Development and not simply a “nice-to have” supplemental activity like I assumed before.

Why is Mocking Critical?

  1. It makes debugging easier - When a database driven test fails, the problem could be anywhere and in my experience it is most often related to a problem with the initialization script (i.e. accidental order-based test dependencies). This often led me to ignore test failures when I was pressed for time because I knew that it was likely just another false alarm. However, when a test that uses mock objects fails, I am not only fairly certain that it is a problem with the code rather than the test, but I also know exactly where the problem is because I’ve guaranteed the behavior of every piece of code except the part that I am trying to test.
  2. It makes writing tests faster and easier - One of the biggest barriers to adoption for TDD for most developers continues to be the perception that it takes too long. I can give a dozen reasons why that perception is wrong, but in the end I think it is more productive to simply find ways to shorten that process. That is exactly what mocking does. Writing out a series of Expect.Call() statements is an order of magnitude faster than trying to write data manipulation statements.
  3. It makes tests execute faster - Don’t underestimate the power of fast feedback. Even if you are not a die-hard continuous integration practitioner, you have to admit that the longer your tests take to run the less likely you and other developers will be to actually run them. Even if you do religiously run them at night, the longer feedback cycle dramatically decreases one of the main benefits of TDD, which is the increased coding speed that comes from test-backed confidence and not having to waste time on excessive analysis and fretting about possible unknown collateral damaged.

What does Mocking Require?

  1. Interface Based Programming - If you use Rhino.Mocks, then every class that you mock must implement an interface. With the help of ReSharper, interfaces can be created from an existing class and propagated to the rest of your codebase with just a few keystrokes. This alone makes the price of ReSharper worth it if you are going to start using mocking in a Legacy system that was designed without using interfaces.
  2. Dependency Injection - One of the first stumbling blocks I ran into came from complex collaborations from objects that weren’t able to be mocked because they were created inside of methods. You can quickly get around this with a little refactoring by making collaborating objects private member variables and then adding a constructor overload to expose them during testing. It is usually a relatively fast and low-risk design change to make.
  3. Identifying Code Seams - If you find yourself getting frustrated and beginning to think that you are stuck in a code base that is impossible to mock, then stop and read the book Working Effectively With Legacy Code by Michael Feathers. I’m about a quarter of the way through this right now and it is one of the most helpful tech books I’ve ever read. The author is fearless and infinitely resourceful when it comes to getting code of any language and any quality under test. In fact, many of his examples are in C++ and even C, so that means that you have no excuses when it comes to your own project. He gives lots of practical advice on how to find the “seams”, which are the easiest and most cost-effective places to modify code so that you can begin to mock it.

A Practical Example?

Here is an MbUnit test that I wrote today before I tackled a production bug that was assigned to me. It mocks the IPaymentTypeItem, which has read-only properties and thus is normally only allowed to be populated from the database. The Expect.Calls() are just done for the methods and properties calls that are actually made on the object in the piece of code I am testing. You can get a full tutorial with better explanations of the API calls here.

 

   1: [RowTest]
   2: [Row("%B409999999999999^Russ's Coffee Emporium^09011211000019900000000?;","409999999999999")]
   3: [Row(";4409999999999999=090112110000199?","409999999999999")]
   4: public void Should_Load_Correctly_With_Partial_Track(string trackData, string expCardNumber)
   5: {
   6:     MockRepository mocks = new MockRepository();
   7:     IPaymentTypeItem payment = (IPaymentTypeItem) mocks.DynamicMock(typeof (IPaymentTypeItem));
   8:     Expect.Call(payment.BinFirstDigit).Return(expCardNumber.substring(0,1));
   9:     Expect.Call(payment.IsCreditCard).Return(true);
  10:     Expect.Call(payment.PaymentTypeValue).Return(PaymentType.VisaCard);
  11:     mocks.ReplayAll();
  12:     FinancialCardEncoding encoding = FinancialCardEncoding.CreateCardEncoding(trackData,payment,true);
  13:     Assert.AreEqual(0,encoding.Errors.Count);
  14:     Assert.AreEqual(expCardNumber,encoding.PrimaryAccountNumber);
  15:     mocks.VerifyAll();

Rhino.Mocks is certainly not the only mocking framework out there, but so far I like it because it takes a strongly typed approach rather than relying on strings which means I get to use intellisense. Whatever framework you do choose, I highly recommend that you take the time to learn it well and incorporate it thoroughly into your development as soon as possible.

Friends Don’t Let Friends Use the Start Menu

I’ve read and listened to Scott Hanselman sing the praises of SlickRun for a long time, but I just recently got around to using it.

For those of you who are as slow to catch on as me, it is essentially just a tricked-out version of the Run window that allows you launch programs much faster than you can through the traditional hide-and-seek start menu approach. This is especially true if you are a tool addict and have a start menu that stretches across your screen.

Best of all, it is FREE, which is one of the few things that still fits into my budget these days. It also only takes seconds to grok and begin saving time with it.

To get started, all you have to do is right-click on the floating SlickRun textbox and select “New Magic Word”. When the dialog box with the nifty wizard hat pops up, you simply drag the magic geen lightsaber circled below over to an open program and it will figure out the program’s filepath. You can also create the mapping by just dragging a shortcut from the start menu on to the floating SlickRun textbox prompt.

Next, you think of a clever and creative keyword (for example NCoverExplorer for NCoverExplorer) and then optionally assign paramters to it. Parameters are cool because you can do things like open FireFox and surf to your favorite porn site in one swift and efficient motion. For NCoverExplorer, I set the parameter value to the path of the NCover xml result file that gets generated from our automated build process.

Finally, thanks to the magic of intellisense, you just have to type a couple of letters until the keyword you want appears in the textbox and then hit return in order to launch it. Easy, huh?

Just remember, REAL geeks don’t use the start menu. If you don’t want all the other geeks laughing at you and kicking silicon dust in your face in the computer lab, then I suggest you download SlickRun immediately.

Helpful Configuration Hints

  • If you’re used to Windows-R to launch programs, you can change the default SlickRun hotkey (Windows-Q) to this more familiar one by setting GrabWinR=1 in the slickRun.ini. You can find this config file in your computer’s app data directory (directory locations vary based on the OS), but it won’t actually be created until you close SlickRun for the first time.
  • I also like turning the ChaseCursor option on so that launcher window pops up where ever your cursor happens to be after hitting the hotkey combination. This saves me from having to shift my focus to a different part of the screen… Yes, I know that it seems lazy beyond words to recommend a feature just because it saves my eyeballs from having to move a few centimeters.

Notes about Vista

  • SlickRun is not quite as compelling on Vista because of the built in launcher in the Vista start menu. However, I still like using it on Vista because it offers more flexibility in terms of creating more logical words for program names as well as automatically passing in parameters to the program.
  • Setting up magic words by dragging shortcuts from the start menu to the SlickRun prompt doesn’t work on Vista for some reason.

Interesting SlickRun Factoid

  • This was actually written in Delphi. I’m going to let you come up with your own Delphi jokes so as to avoid any hate mail from either one of the remaining Delphi programmers out there.

A Touching VSS Moment

Today it was decided that a bug fix that I recently added to our production branch in Visual Source Safe would not be included in an upcoming hotfix release as originally planned, so I was asked to remove it.

My fix only touched 6 files, so my first thought was just to do it manually. Then I saw the rollback button in the ‘Show History’ window. If I were a betting man, I would have put good money on this functionality not only failing, but also wreaking havoc with our version history. However, I was feeling strangely brave today so I held my breath and clicked the button anyways.

Contrary to all expectations, it actually worked. It erased the historical records that came after the version I rolled back to, but since I already had those changes merged into the mainline I was in a forgiving mood and considered it an unfettered success.

In fact, I was so pleasantly surprised that I started to utter what might have been the first positive words about VSS that ever came out of my mouth. However, before I could finish my sentence I was greeted with this response.

I guess VSS was verklempt due to my kind words. Either that or it detected the ever so subtle note of sarcasm in my voice and closed in a huff. Truth be told, I don’t think it ever forgave me for the poem I wrote about it several weeks ago.


I bet SubVersion is not this sensitive to criticism.

A Couple Firefox Add-On Gems

This week I installed a few nifty Firefox Add-Ons, All-In-One-Gestures and IE Tab.

I tried All-In-One-Gestures after watching how fast a co-worker was able to navigate on the
web by using this Add-On. It allows you to right-click anywhere on a web page and move the mouse left to go backward or right to go for forward.

Navigating this way is definitely much faster than using the browser toolbar buttons and helps me stay in a better flow when trying to quickly scan oodles of google results.

For some reason I also really like the little red line affect that shows up on the page, but I’m easily impressed like that.

The other Add-On, IE Tab, lets you view how a web page will be displayed in Internet Explorer by simply clicking on a button at the bottom of the page. This came in handy when I was trying to figure out why a Cruise Control report generated by FxCop was not working. On a hunch, I toggled to IE and realized that the XSL had browser compatibility issues because it worked fine in IE. It was nice to be able to verify this by simply toggling view modes rather than having to start a different browser and then navigate to the page.

The moral of the story: Always pay attention to how your co-workers do things. I don’t think I ever met somebody who didn’t have at least one time saving tool or trick up their sleeves that I could steal to my great benefit. I like to think of every productivity enhancing tool or technique as a little investment. It may take a little “seed money” in terms of time and effort, but it is amazing how quickly the dividends begin to pay off so that my overall time savings quickly surpasses my initial investment.

EditPlus: A Kinder, Gentler Way To Build Nant Scripts

I’ve been working on Nant scripts this week and the experience has been much more enjoyable since a co-worker showed me how he used EditPlus (thanks Raoul). After a few quick customizations, I was able to not only get syntax highlighting for my build files but also execute Nant from within the tool and see the output from the bottom pane. Anything that decreases context switching when I have a gajillion windows open is pretty nifty in my book.

Here’s a picture of a build file with my custom button circled at the top and the nant output in the bottom pane..



Here are a list of tweaks that I made:

  • For syntax highlighting:

    1. Under the Document menu, go to ‘Change File Type’ and select XML.
  • To create a custom button that will execute the build you are editing:

    1. Select ‘UserToolbar’ under the View menu to get the user configurable buttons to appear.
    2. Click on the first button (the hammer icon) of the user toolbar that appears and choose ‘Configure User Tools’.
    3. On the dialog box that appears, click the ‘Add Tool’ button and select ‘Program’.
    4. For the Command field, navigate to the location of your Nant executable.
    5. For Argument field, enter the buildfile argument (-f:) and then choose ‘FileName’ from the drop down so that the name of the current build file you are editing will dynamically be sent as a command line parameter.
    6. For the Initial Directory textbox, choose ‘File Directory’ so that the path of the current file will be dynamically sent as a command line parameter.
  • To view the output from Nant in the bottom pane:
    1. Click on the ‘Capture Output’ checkbox from the previous dialog box.

In order to execute your Nant script, simply click on the first button that becomes enabled on the user toolbar. This is what the dialog box looks like for the above steps:

Happy Nant scripting!

A Poetic Tribute to Visual Source Safe

Recent source control woes have inspired me to write this little poem about my least favorite source control system.

VSS, I hate you so
And I can not wait to see you go.

You have the word safe in your name
Yet since you came
my IDE has crashed
And my files have been trashed.

If your integration were not so lame,
Then maybe I could do a simple rename;
All I wanted was a little bit of history
But a few files I did purge and now it’s all a mystery.

Branching and merging is something we no longer dare
So we copy and paste with much care;
A changeset would help reduce the friction
and make release reports seem less like fiction.

If only you would realize
that it should not take days to Analyze;
And it is wrong that I should have to be leery
when all I want to do is a simple query.

Because of your file based sharing
About disk space and security we gave up caring;
Haven’t you heard of atomic commits?
If so, perhaps my project wouldn’t be on the fritz.


If only I could create a simple diversion.
Then I could quickly upgrade to Subversion.
Perhaps if we had Perforce or Vault
Then our development wouldn’t grind to a halt.


VSS, I hate you so
And I can not wait to see you go.

For a non-rhyming look at some of the short-comings of VSS, I recommend this article by Alan de Smet.

Next Page »