Wednesday, June 25, 2008

Reducing email distractions

Email has the potential to be very distracting. How many times a day do you check your email? Everytime that little Outlook notification pops up about a new email coming in, don't we all immediately go read it? That's a lot of interruptions in a typical day.

As of this morning, I'm trying out a new way to process email to reduce those distractions. I'm going to check my inbox just three times a day: first thing in the morning, around noon, and at the end of the day. I hope to get that down to two checks a day eventually.

I've turned off the default Outlook notifications. I've removed the Outlook icons from the notification area in the taskbar. I set up a new rule to pop up an alert if I get an urgent email (so if you need me to respond immediately, mark it urgent).

To make sure I don't need to spend much time in my inbox, I use a system very similar to that described in Getting Things Done where I immediately process the items in my inbox. They go into one of several specially named folders I created: @Action - Now, @Action - Soon, @Someday, @Waiting; or they get deleted; or they get moved into one of my reference folders (I have one for each project). The special folders start with "@" to sort them to the top of the folder list in Outlook. By moving things into one of these folders immediately, it keeps the inbox very clean.

@Action - Now is for emails I need to act on today. @Action - Soon is for things I need to act on but at a lower priority. @Someday are things I want to read in more detail and possibly act on later. And @Waiting is for emails that I can't do anything with yet because I'm waiting on someone else.

I'm one of the few people who actually likes the Outlook Today feature in Outlook. I have it configured to show me the next 7 days of my calendar, my task list, and the message counts of my inbox and the four special folders I mentioned above.

I'll let you know how it all works out.

Defining .NET properties the easy way

Once you've done a fair amount of programing in .NET, it quickly becomes tiresome to define your custom properties in code:

private int myProperty;
public int MyProperty

{
get { return myProperty; }
set { myProperty = value; }
}

It gets to the point where you seriously consider just declaring everything as a field instead:

public int MyProperty;

But resist the temptation! There are downsides to this including difficulties with databinding and all sorts of issues if you later change your mind and want them to be properties.

So, stick with properties but make your life a little easier by using the built-in prop snippet. When you want to create a new property, just type prop and hit Tab twice and Visual Studio will insert a nice template for creating the property. You can tab through the fields in the template and easily change the type and name to what you want.

And here's the really good news: the new version of C# that comes with Visual Studio 2008 includes a feature called Automatic Properties. This allows you to define basic properties using this syntax:

public int MyProperty { get; set; }

Behind the scenes, the C# compiler translates this to (basically) the same code as if you'd used the more traditional syntax.

For more information on Automatic Properties, see this post from Bart De Smet's blog.

Storage of NULL values in SQL Server

Earlier today a couple of team members asked whether NULL values in a database take up any space. I wasn't sure of the answer so I did a little research which I decided to share here in case anyone is interested.

The quick answer is no, NULL values don't take up any additional space. However, each column does take up a certain amount of space whether or not it contains any data. Fixed datatype columns (int, float, char, etc.) take up a specific amount of space depending on the size of the datatype (int=4 bytes, smallint=2 bytes, float=4 or 8 bytes). Variable length columns (varchar, varbinary) take up a minimum of 2 bytes per column even if empty (to store the actual length pointer).

The NULL status of each column is stored in a special part of the row called the NULL bitmap that contains one bit for each column, in 8-bit chunks. So a table with 1-8 columns has a one byte (8 bit) NULL bitmap but a table with 9-16 columns has a two byte (16 bit) NULL bitmap.

If you’re interested in the detailed version, be sure to check out Inside Microsoft SQL Server 2005: The Storage Engine, which I highly recommend with the rest of the series.

The document was sent to the printer

I click the Print button in Word (or any application) and I quickly get a popup in the taskbar telling me "The document was sent to the printer."

What a surprise--I wouldn't have expected that!

That popup has to be the most annoying Windows feature. It's unbelievable that it still remains even in Vista. Of course my document was just sent to the printer--I just printed it!

A useful message would be one that told me when it was finished printing.

And (in my opinion), they don't make it easy to figure out how to turn these messages off. But I eventually tracked it down (here is the Vista version):

1) Control Panel -> Printer
2) Right click and select Server Properties...
3) Go to Advanced tab and uncheck Show information notifications for network printers.
4) Click OK and print away.