Thursday, August 14, 2008

Shortcuts revisited

Two days ago, I posted about some of my favorite keyboard shortcuts. Coincidentally, yesterday I was catching up on my podcast listening, and Hanselminutes #125 is an interview with Saqib Shaikh, a blind developer with Microsoft Consulting Services in the UK. Without sight, Saqib is unable to use the mouse, so he must make extensive use of keyboard shortcuts. I have trouble remembering twenty, or so, shortcuts and can’t imagine what it must be like to need to remember them for almost every task. If you haven’t heard the podcast, check it out. It makes you think about the overall development experience, and you might even pick up a few new shortcuts (how many people knew that Ctrl+Shift+Esc opened the task manager?).

Tuesday, August 12, 2008

Favorite Shortcut Keys

Like most developers, I make extensive use of shortcut keys. However, I seem to only have the mental capacity to remember 20-30 at one time. So, I have a tendency switch them in and out of my regular rotation depending upon what type of project I am working on. Here are the ones that I get the most use out of:

Visual Studio
(Note: some of these are different dependent upon your installation settings)
Control + g : Goto line number
Shift + Alt + Enter : Toggle full screen mode
Control + Space : Launch intellisense
Tab : Accept intellisense selection
F5 : Start debugging
F6 : Build
F10 : Step Over
F11 : Step Into

Windows
Windows Key + f : Search for documents
Windows Key + r : Run
Windows Key + m : Show the desktop (minimize all applications)
Alt + Tab : Toggle between applications

Most applications
Control + s : Save
Control + c : Copy
Control + v : Paste
Control + z : Undo
Control + n : New document
Control + x : Cut
Control + a : Select all
Control + h : Replace
Control + f : Find
Control + Tab - Toggle between documents

Thursday, August 7, 2008

iPhone-a-licious

Up until now, I hadn’t jumped on the iPhone bandwagon. However, yesterday I was listening to an automotive podcast, and they mentioned a new iPhone app called Dynolicious. You install the software on your iPhone, and then place the phone in your car while driving. The software can then be used to calculate the car’s performance statistics, such as 1/4 mile ET’s, 0-60 times, horsepower, etc. While, there are devices (such as the G-Tech) that can calculate these statistics, they can’t be used to make calls, take pictures, play music, surf the web, etc., etc., etc.

Hearing about this software was one of those “blow your mind” moments for me. It is an amazing application of the iPhone’s technology, and also made me think about just how powerful the iPhone is. It will be interesting to see what other creative applications will become available for the phone. Gaming possibilities could be a huge use of the technology. While it’s not exactly a Nintendo Wii, tapping into the accelerometers could lead to some exciting gaming on the small screen. After a quick look at the iPhone app store, and it looks like there are already a few games that utilize the accelerometers, but it could be fascinating to see what else is available in the upcoming months.

It might be time to go phone shopping this weekend….

Tuesday, August 5, 2008

Quantity leads to Quality…

A few days ago Jeff Atwood wrote a blog post about the parallels between software development and the advice for artists in the book “Art & fear”. This quote sums up the basic idea:

“When it comes to software, the same rule applies. If you aren't building, you aren't learning. Rather than agonizing over whether you're building the right thing, just build it. And if that one doesn't work, keep building until you get one that does.”

I found this to be an interesting post because I had recently came to the same conclusion. At my current employer there is a senior developer who is effectively my mentor (we’ll just call him Frank). He insists that all code should follow his standards, which is ok because they are typically good standards; but the whole thing can be a little intimidating. During my first few weeks at the employer, I had a difficult time completing any work because I was constantly worrying about “how would Frank handle this task?”. Once I overcame this, and just let the code flow, I have been much more productive and have learned more by writing the code as opposed to trying to over-analyze the existing code base.

Jeff suggests that the same idea of “Quantity always trumps quality” applies to blogging as well. As an aspiring blogger, I guess I should take that message to heart….

Accessing the Office Ribbon from VBA

Yesterday I received this email from a co-worker (who shall remain anonymous):

1. Open an instance of Word 2007 to find the msoId of the button you’d like to press. You can find this by going to Office Button Word Options Customize to view a list of commands which correspond to buttons.

2. Hover over the name of the command and you’ll see a tooltip; for example, the tooltip for the Save command when selected from the “Popular Commands” list says “Popular Commands Save (FileSave)”. The part in parentheses is the msoId. (Note: You may have to select the name of a tab in the “Choose commands from:” list box to find the button you’re looking for.)

3. In your code, call Word.Application.CommandBars.ExecuteMso with the msoId and you can invoke the button.

Note: The steps above also apply to Excel.

Code Example to demonstrate how to press FileSave in Word 2007

[VBA]
Sub PressThisRibbonBarButton()
On Error Resume Next
If Word.Application.Documents.Count = 0 Then Exit Sub
' Press the Save button Word.Application.CommandBars.ExecuteMso "FileSave"
End Sub


I haven’t worked with the Office 2007 API yet, but I thought this seemed like a good tip that was worth posting here. However, today I was researching something else, and discovered a post on the Interwoven Devnet forums by someone named jny. It looks like the previously mentioned co-worker was trying to pull a fast one, and borrow jny’s post. Anyway, I still thought this was helpful, so thanks to jny from the Interwoven forums for the helpful tip.

Tuesday, July 22, 2008

2010 Camaro

Yesterday Chevrolet revealed the production 2010 Camaro to the public. Video of the event can be seen here. I've been a long time fan of the Camaro, and have had high expectations of the new model ever since the concept was released. Based on the information so far, it appears that the car is going to live up to my high hopes, and beyond. Looks like it's time to start making room in my garage for a new addition!


Thursday, July 3, 2008

Troubleshooting Datasets

Lately I have been working a lot with strongly typed datasets, and have found that they can be difficult to troubleshoot when faced with the dreaded error message:

"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

After some research, I found a blog post by Roy Osherove where he had faced the same problem. In this post, Sanjay lists the following suggestion:

"Essentially, when I see the message above, I check the HasErrors property for each DataTable in the data set and then invoke the GetErrors method on the tables reporting errors. The GetErrors returns a collection of DataRows and you can invoke the .RowError property on the each of the error-stricken rows to find out just exactly what the problem is... "

His suggestion has made troubleshooting much easier. Just disable constraints on the dataset, and then write code to catch the problem once contraints are enabled. Here is a snippet of the version that I came up with:

try


{


    this.EnforceConstraints = true;


}


catch


{


     foreach(DataTable dt in this.Tables)


    {


        if (dt.HasErrors)


        {


            DataRow[] rowErrors = dt.GetErrors();


 


            for (int i = 0; i < rowErrors.GetLength(0); i++)


            {


                System.Windows.Forms.MessageBox.Show(dt.TableName + ": " + rowErrors[i].RowError.ToString());  


            }


        }


    }


}