Boost your productivity

Here are a few things I do to boost my coding productivity. Everybody’s different so results may vary.

It’s All About Flow

Flow is my goal. All of these things are targeted at creating and maintaining flow. For me flow is best described as an intense focus to the point of being absorbed in the task at hand with little thought directed at how you are actually doing it.

Flow happens when I forget about the code and the language I’m coding in. I forget about the tools I’m using and what my fingers are doing and sometimes I even forget to eat. For me it’s very similar (and similarly gratifying) to the experience I get when I’m downhill skiing and I’ve practiced enough that I don’t have any issues with balance; It all clicks and feels right. I’m absorbed in where I want to go and the breathtaking views rather than what my legs, arms, and body are doing (or not doing) to get me there. It may also be similar to how an NHL hockey player is focused on watching the puck fly into the net, not what his left skate is doing, and the position of his hands on the stick. If you’ve never experienced flow, I may not have found an analogy that works for you, but trust me, being in the flow feels fantastic and is very productive.

Get Comfortable

When it comes to programming you have to be extremely comfortable with all of the practices, technologies, and tools you’re using. This may take years and years, but eventually with enough time and effort you will get there. 

Even if you are completely comfortable with your tool-set there are other things that can get in the way of a good intense rip-it-up coding session:

Isolate Yourself

I typically need 3+ hours of total isolation to really get the flywheel up to maximum RPM. There might be certain tricks you can use to get into the flow even faster. High tempo electronic music with no lyrics  (or repetitive lyrics) really works for me. After about an hour of isolation I’m pretty close to peak performance, but one interruption can set me back another hour. Once I get in the flow and am not distracted I can maintain it for 4-8 hours. Also, the longer I’ve been flowing the easier it is for me to continue in the flow after a short distraction.

 Fine-Tune Your Tools

I set the computer up so I don’t have to interrupt the flow to get things done. Some things that interrupt my flow: hunting for things in the Start menu, looking for a file in a directory with a million files in it, waiting for a compile, waiting for key-strokes to appear on the screen, using the mouse rather than a short-cut-key.

I like my coding environment to be as seamless as an xbox game. If I’m playing Halo and I’m in the middle of killing 1,000 bad-guys (I know. 10 is a stretch for me, but hear me out.) and the game pauses to garbage collect, then Halo minimizes and a window pops up to let me know a virus scan has completed. I’m a bit frustrated, but I kill the pop-up and go back to Halo. I get back into the groove and realize I need to switch weapons, so I open a series of cascading menus, hunting for the work MS-Halo Weapons, by the time I find it and click on the weapon I want I’m dead.  Arghhh.  I’m not really having fun. For gaming an experience like this is unacceptable and I think it’s unacceptable for coding too.

Memorize & Create Short-cuts

If there is a short-cut key for something, memorize it and use it. Switching from just getting it done to hunting for something in a menu or a list is one of the biggest flow disruptors for me. I’m not sure this is universal, but many highly-productive people I know swear by shortcuts. It makes perfect sense to me. You’re cutting down the amount of work your brain has to do to go from “I want to do XYZ” to actually doing XYZ. It cuts out the hunting step completely.

Keep Tuning

You may find other things I haven’t mention that help you get into the flow, or disrupt your flow. Learn to notice these things and adjust what you’re doing to enable yourself to get into the flow and stay there more often. It will pay off more than you can imagine.

Productivity Tools

Here are some tools I use to help me be more productive:

Launchy - http://www.launchy.net/

Launchy is my replacement for the Start Menu. I almost never open the start menu just to browse around to see what kinds of things are in there. I always know exactly what I want to launch. Excel, Word, iTunes, Sql Server Management Studio, etc.

For example, I just hit CTRL+SPACE and type excel, hit enter and Excel pops up. It’s awesome.

SlickRun - http://www.bayden.com/SlickRun/

I use SlickRun to create magic words (shortcut words) to web sites and other tools.

For example, I just hit WINDOWS+Q and type jira - hit enter and Jira pops up in my browser on my Jira homepage. I have shortcuts for wiki, searching amazon, .NET class library, google reader, teamcity, opening my vm, opening cmd windows in various directories

Have any tips on achieving and maintaining flow or other tools you’d like to share?

Why do you own your servers?

Just because you can doesn’t mean you should. Today’s startup companies are able to launch innovative, web-based companies at a fraction of what it cost only a few years ago primarily because they don’t own their servers and they don’t manage them. They outsource that to companies that are able to take advantage of economies of scale by specializing in provisioning scalable computing and storage resources.

A prime example is recent startup Mogulus, where some 15,000 people host live 24/7 streaming tv channels. Mogulus is hosted entirely using Amazon’s EC2 (elastic compute cloud) and S3 (simple storage service) services.

More and more companies will be enjoying cost savings and decreased operational complexity without sacrificing availability and scalability thanks to elastic compute clouds.

Amazon EC2 is commonly used to run linux instances. For those interested in running .NET applications, check out this post: EC2 Amazon - QEMU Windows Images.

Testing code that depends on a database

I often get asked questions about how to test code that relies heavily on a database. People often assume that because an application relies on a database that the test must also rely on a database. Then they get snagged up in all the problems with testing against databases such as not messing up the data for other people and being able to setup the data so that the test can expect a certain result when the Company table is queried for companid 1357, or even which company should be queried for?

“I need a Company record that has more than 500 employees and is publicly traded to test this bit of logic I wrote. Which companyid should I use? Is the data going to change? Should I just create a new test company in the database? I hope nobody touches it.”

My short answer is: Don’t include the database when you’re testing your business logic (unless you are testing business logic that’s in the database, but that’s a whole seperate topic that won’t be covered here).

How do you do that?

  1. Seperate the code that accesses the database from your business logic implementation.
  2. Create a well-defined interface for that data access object. Like ICompanyDataAccess.
  3. Test the business logic by plugging a Mock object in to replace the database implementation of the data access object.

For further reading, refer to this excellent blog post on mock testing with NMock:  http://msdn.microsoft.com/msdnmag/issues/04/10/NMock/

Comments, questions, or experiences relating to mock testing or seperating business logic from data access? Please comment below.

Watir assisted manual testing results

Okay, that was easy!

I have three separate Watir scripts written to open IE and:

  1. Automatically login with a valid test username and password
  2. Login with a valid username and invalid password
  3. Login with a non-existent username

Manually each of these procedures take about 25 seconds. Running these using Watir from my ruby editor takes about 5 seconds. That’s 5 times faster!!!

If I estimate that I need to log into that app 100 times today to do my manual testing, I’ll be spending 8 minutes logging in rather than  42 minutes. I’m already going to save aproximately 2,000 seconds or 33 minutes of wasted time (it took less than 5 minutes to write the scripts). Multiply that by 10 developers and that’s a savings of over 5 hours per day! That could be another feature.

Speeding up manual testing with Watir, WatiN, and WatirRecorder

I’m changing some untested code today and I want to make sure I’m not breaking things as I go, but I don’t want to slow down my development because timelines are tight.

I’m going to use Watir and WatirRecorder (was WatirMaker) to help speed up my manual testing through the user interface. If that goes well I might add some asserts where it makes sense. If I have time I’ll check out WatiN as well.

I’ll write another post to let you know how it went.