Dutton's blog

Silly for loop syntax

I've been working with C-style languages for over 12 years now, but stumbled across this funny for loop syntax in a code tutorial today and had to double-take:

for (int i = 2; i --> 0;)
{
    // do something
}

Although technically correct, quite what you gain from putting the iterator within the condition apart from confusion is lost on me.

A PRISM Notifying Backing Property Snippet for Visual Studio

When writing View Models deriving from NotifyingObject in PRISM I find myself endlessly having to write public notifying properties backed by private fields. To save my fingers, here's a Visual Studio snippet I use:



  
    
Expansion PRISMNotifyingBackedProperty Richard Dutton A PRISM Notifying Backed Property propprism
_myProperty Private backing property name _myProperty MyProperty Public property name MyProperty int Property type int $MyProperty$); } }]]>

To use it:

  • Copy and paste the xml into a new file.
  • Save it as "PRISMNotifyingBackedProperty.snippet".
  • In Visual Studio open the Code Snippet Manager (Tools -> Code Snippets Manager).
  • Click the Import button and navigate to the file you saved.
  • When it prompts you where to add the snippet, chose My Code Snippets, click Finish, then OK.

You can now type "propprism" into your code and hit Tab to insert the snippet.

Hope this helps.

So long... and thanks for all the Red Bull

Today was my last day at Red Bull Technology. For the past three years I've been working for the quadruple double championship winning Formula One team and I must admit, I'm going to miss it.

Infiniti Red Bull Racing logo

I feel proud to have worked in such a fascinating industry, learning new tools and technologies with some of the most hard-working, talented and dedicated people I've ever met. I never followed F1 before joining but I'm definitely a fan now. It'll be strange watching the sessions without supporting my software but I know it's in good hands. I look forward to watching the seasons unfold, and hopefully more double championship wins for Red Bull! 2014 is certainly going to be an interesting season for everyone involved so I wish them every luck.

Infiniti Red Bull Racing Pit Wall

My career so far has taken me from central government communications via industrial control systems to F1, they've all involved software engineering, and for the past 7 or so years .Net, so what's in store for me next?

Career So Far Icons

My future employer would rather I not name them, which is fine by me. The bright lights of London are my next destination; swapping the M1 and the stupidly impractical car for the 0700 train from Northampton, a whole new industry and domain to get my head around, and a new team to work with and learn from. I'm still in software, and still very much .Net so some things don't change, but I'm very excited by the new challenge and looking forward to starting on the 20th January. One upside of my new train commute is that I'll get some more time to work on blogging and personal projects so armed with my new toy I hope to manage a few more blog posts this year.

To all of my former colleagues at RBR/RBT, again, thank you for such an amazing time, and good luck in the future!

3 for 1 MCSD Microsoft Exam Promotion

Microsoft Virtual Academy has just launched a new exam certification promotion; 3 for 1 on all of their exams which count toward the following Microsoft Certified Solutions Developer (MCSD) certifications:

Only available until 31st May 2014, click here for more info and to book.

As I've previously blogged about, here, here and here, I've taken a few of these exams across both the HTML5 and C# Windows Store certifications and found them really good for both validating existing knowledge, filing in gaps and learning completely new stuff so would highly recommend them.

How to debug JavaScript in a Visual Studio 2013 ASP.NET Web Application

I've been struggling trying to debug my JavaScript in ASP.Net Web Applications under Visual Studio 2013, it lets me place a breakpoint in the script:

Placing a breakpoint

But then I hit F5 to run my application under the debugger and it gives me "The breakpoint will not currently be hit. No executable code of the debugger's target code type is associated with this line":

Breakpoint error

Which is a bit rubbish. I'm sure they have their reasons for letting me place a breakpoint and then so cruelly toying with my emotions in this way but still, it doesn't help me single-step through the nail-biting outcome of my (a < b) conditional, which is frustrating to say the least.

Although not ideal (as it involves making code changes to your code), you can cause Visual Studio to break during execution by adding the keyword

debugger;

to your code like this:

Adding the debugger keyword

Fire up the debugger again and you'll find it break at the line.

Visual Studio breaking at the debugger line

It seems to strip out any syntax highlighting while its in this state but at least you can hover over fields to see their value and use the Immediate Window and all the usual Debugger trickery pokery without having to resolve to something like Firebug or IE's F12 Developer Tools.

A big shout out to my good friend Jarek for showing me this. Check out his awesome productivity extension for Visual Studio, VSCommands.