Debug.Assert replacement for Phone and Store apps

Sun, January 13, 2013, 09:42 PM under MobileAndEmbedded

I don’t know about you, but all my code is, and always has been, littered with Debug.Assert statements. imageI think it all started way back in my (short-lived, but impactful to me) Eiffel days, when I was applying Design by Contract. Anyway, I can’t live without Debug.Assert. Imagine my dismay when I upgraded my Windows Phone 7.x app (Translator By Moth) to Windows Phone 8 and discovered that my Debug.Assert statements would not display anything on the target and would not break in the debugger any longer! Luckily, the solution was simple and in this post I share it with you – feel free to teak it to meet your needs.

Steps to use

  1. Add a new code file to your project, delete all its contents, and paste in the code from MyDebug.cs
  2. Perform a global search in your solution replacing Debug.Assert with MyDebug.Assert
  3. Build solution and test

Now, I do not know why this functionality was broken, but I do know that it exhibits the same broken characteristics for Windows Store apps. There is a simple workaround there to use Contract.Assert which does display a message and offers an option to break in the debugger (although it doesn’t output the message to the Output window). Because I plan on code sharing between Phone and Windows 8 projects, I prefer to have the conditional compilation centralized, so I added the Contract.Assert workaround directly in MyDebug class, so that you can use this class for both platforms – enjoy and enhance!

Perfect is the enemy of “Good Enough”

Sun, January 13, 2013, 08:55 PM under Career

This is one of the quotes that I was against, but now it is totally part of my core beliefs:

"Perfect is the enemy of Good Enough"

Folks used to share this quote a lot with me in my early career and my frequent interpretation was that they were incompetent people that were satisfied with mediocrity, i.e. I ignored them and their advice. (Yes, I went through an arrogance phase).

I later "grew up" and "realized" that they were missing the point, so instead of ignoring them I would retort: "Of course we have to aim for perfection, because as human beings we'll never achieve perfection, so by aiming for perfection we will indeed achieve good enough results". (Yes, I went through a smart ass phase).

Later I grew up a bit more and "understood" that what I was really being told is to finish my work earlier and move on to other things because by trying to perfect that one thing, another N things that I was responsible for were suffering by not getting my attention - all things on my plate need to move beyond the line, not just one of them to go way over the line. It is really a statement of increasing scale and scope.

To put it in other words, getting PASS grades on 10 things is better than getting an A+ with distinction on 1-2 and a FAIL on the rest. Instead of saying “I am able to do very well these X items” it is best if you can say I can do well enough on these X * Y items”, where Y > 1. That is how breadth impact is achieved.

In the future, I may grow up again and have a different interpretation, but for now - even though I secretly try to "perfect" things, I try not to do that at the expense of other responsibilities. This means that I haven't had anybody quote that saying to me in a while (or perhaps my quality of work has dropped so much that it doesn't apply to me any more - who knows :-)).

Wikipedia attributes the quote to Voltaire and it also makes connections to the “Law of diminishing returns”, and to the “80-20 rule” or “Pareto principle”…

it commonly takes 20% of the full time to complete 80% of a task while to complete the last 20% of a task takes 80% of the effort

…check out the Wikipedia entry on “Perfect is the enemy of Good” and its links. Also use your favorite search engine to search and see what others are saying (Bing, Google) – it is worth internalizing this in a way that makes sense to you…

Best of "The Moth" 2012

Tue, January 1, 2013, 07:31 AM under Personal

As with previous years (2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011) I’d like to wish you a Happy New Year and share a quick review of my blog posts from 2012 (plus speculate on my 2013 blog focus).

1. Like 2011, my professional energy in 2012 was dominated by C++ AMP including articles, blog posts, demos, slides, and screencasts. I summarized that over two posts on the official team blog that I linked to from my blog post here titled: “The last word on C++ AMP”, which also subtly hinted at my change of role which I confirmed in my other post titled “Visual Studio Continued Excitement”.

2. Even before I moved to the Visual Studio Diagnostics team in September, earlier in the year I had started sharing blog posts with my thoughts on that space, something I expect to continue in the new year. You can read some of that in these posts: The way I think about Diagnostic tools, Live Debugging, Attach to Process in Visual Studio, Start Debugging in Visual Studio, Visual Studio Exceptions dialogs.

3. What you should also expect to see more of is thoughts, tips, checklists, etc around Professional Communication and on how to be more efficient and effective with that, e.g. Link instead of Attaching, Sending Outlook Invites, Responding to Invites, and OOF checklist.

4. As always, I sometimes share random information, and noteworthy from 2012 is the one where I outlined the Visual Studio versioning story (“Visual Studio 11 not 2011”, and after that post VS 11 was officially baptized VS2012) and the one on “How I Record Screencasts”.

Looking back, unlike 2011 there were no posts in 2012 related to device development, e.g. for Windows Phone. Expect that to be rectified in 2013 as I hope to find more time for such coding… stay tuned by subscribing using the link on the left.

Join the Visual Studio diagnostics team

Fri, December 14, 2012, 10:42 AM under Career

I have a Program Manager position open on the Visual Studio diagnostics team which owns the debugger, the profiler tools, and IntelliTrace.

If you have never worked for Microsoft you may be wondering if the PM position at Microsoft is for you. Read the job description to see what the role entails and to see if you are a fit.

I’ll preempt the usual question and say that this is a Redmond-based position. Beyond that, if you are interested in what you read and you think you have what it takes, then email me.

OOF checklist

Fri, November 16, 2012, 02:05 PM under Communication

When going on vacation or otherwise being out of office (known as OOF in Microsoft), it is polite and professional that our absence creates the minimum disruption possible to the rest of the business, and especially our colleagues.

Below is my OOF checklist - I try to do these as soon as I know I'll be OOF, rather than leave it for the night before.image

  1. Let the relevant folks on the team know the planned dates of absence and check if anybody was expecting something from you during that timeframe. Reset expectations with them, and as applicable try to find another owner for individual activities that cannot wait.
  2. Go through your calendar for the OOF period and decline every meeting occurrence so the owner of the meeting knows that you won't be attending (similar to my post about responding to invites). If it is your meeting cancel it so that people don’t turn up without the meeting organizer being there. Do this even for meetings were the folks should know due to step #1. Over-communicating is a good thing here and keeps calendars all around up to date.
  3. Enter your OOF dates in whatever tool your company uses. Typically that is the notification to your manager.
  4. In your Outlook calendar, create a local Appointment (don't invite anyone) for the date range (All day event) setting the "Show As" dropdown to "Out of Office". This way, people won’t try to schedule meetings with you on that day.
  5. If you use Lync, set the status to "Off Work" for that period.
  6. If you won't be responding to email (which when on your vacation you definitely shouldn't) then in Outlook setup "Automatic Replies (Out of Office)" for that period. This way people won’t think you are rude when not replying to their emails. In your OOF message point to an alias (ideally of many people) as a fallback for urgent queries.
  7. If you want to proactively notify individuals of your OOFage then schedule and send a multi-day meeting request for the entire period.image Remember to set the "Show As" to "Free" (so their calendar doesn’t show busy/oof to others), set the "Reminder" to "None" (so they don’t get a reminder about it), set "Low Importance", and uncheck both "Response Options" so if they don't want this on their calendar, it is just one click for them to get rid of it. Aside: I have another post with advice on sending invites.
  8. If you care about people who would not observe the above but could drop by your office, stick a physical OOF note at your office door or chair/monitor or desk.

Have I missed any?

Responding to Invites

Sun, November 11, 2012, 05:40 PM under Communication

Following up from my post about Sending Outlook Invites here is a shorter one on how to respond.

  1. Whatever your choice (ACCEPT, TENTATIVE, DECLINE), if the sender has not unchecked the "Request Response" option, then send your response. Always send your response. Even if you think the sender made a mistake in keeping it on, send your response. Seriously, not responding is plain rude.
  2. If you knew about the meeting, and you are happy investing your time in it, and the time and location work for you, and there is an implicit/explicit agenda, then ACCEPT and send it.
  3. If one or more of those things don't work for you then you have a few options.
    1. Send a DECLINE explaining why.
    2. Reply with email to ask for further details or for a change to be made. If you don’t receive a response to your email, send a DECLINE when you've waited enough.
    3. Send a TENTATIVE if you haven't made up your mind yet. Hint: if they really require you there, they'll respond asking "why tentative" and you have a discussion about it.
    4. When you deem appropriate, instead of the options above, you can also use the counter propose feature of Outlook but IMO that feature has questionable interaction model and UI (on both sender and recipient) so many people get confused by it.

BTW, two of my outlook rules are relevant to invites. image

The first one auto-marks as read the ACCEPT responses if there is no comment in the body of the accept (I check later who has accepted and who hasn't via the "Tracking" button of the invite). I don’t have a rule for the DECLINE and TENTATIVE cause typically I follow up with folks that send those.


The second rule ensures that all Invites go to a specific folder. imageThat is the first folder I see when I triage email. It is also the only folder which I have configured to show a count of all items inside it, rather than the unread count - when sending a response to an invite the item disappears from the folder and hence it is empty and not nagging me.

Sending Outlook Invites

Sun, November 11, 2012, 05:18 PM under Communication

Sending an Outlook invite for a meeting (also referred to as S+ in Microsoft) is a simple thing to get right if you just run the quick mental check below, which is driven by visual cues in the Outlook UI.


I know that some folks don’t do this often or are new to Outlook, so if you know one of those folks share this blog post with them and if they read nothing else ask them to read step 7.image

  1. Add on the To line the folks that you want to be at the meeting.
  2. Indicate optional invitees. Click on the “To” button to bring up the dialog that lets you move folks to be Optional (you can also do this from the Scheduling Assistant).
  3. Set the Reminder according to the attendee that has to travel the most. 5 minutes is the minimum.
  4. Use the Response Options and uncheck the "Request Response" if your event is going ahead regardless of who can make it or not, i.e. if everyone is optional. Don’t force every recipient to make an extra click, instead make the extra click yourself - you are the organizer.image
  5. Add a good subject
    1. Make the subject such that just by reading it folks know what the meeting is about. Examples, e.g. "Review…", "Finalize…", "XYZ sync up"
    2. If this is only between two people and what is commonly referred to as a one to one, the subject would be something like "MyName/YourName 1:1"
    3. Write the subject in such a way that when the recipient sees this on their calendar among all the other items, they know what this meeting is about without having to see location, recipients, or any other information about the invite.
  6. Add a location, typically a meeting room.
    1. If recipients are from different buildings, schedule it where the folks that are doing the other folks a favor live. Otherwise schedule it wherever the least amount of people will have to travel. If you send me an invite to come to your building, and there is more of us than you, you are silently sending me the message that you are doing me a favor so if you don’t want to do that, include a note of why this is in your building, e.g. "Sorry we are slammed with back to back meetings today so hope you can come over to our building".
    2. If this is in someone's office, the location would be something like "Moth's office (7/666)" where in parenthesis you see the office location.
    3. If some folks are remote in another building/country, or if you know you picked a time which wasn't free for everyone, add an Online option (click the Lync Meeting button).
  7. Add a date and time.
    1. This MUST be at a time that is showing on the recipients’ calendar as FREE or at worst TENTATIVE. You can check that on the Scheduling Assistant.
    2. The reality is that this is not always possible, so in that case you MUST say something about it in the Invite Body, e.g. "Sorry I can see X has a conflict, but I cannot find a better slot", or "With so many of us there are some conflicts and I cannot find a better slot so hope this works", or "Apologies but due to Y we must have this meeting at this time and I know there are some conflicts, hope you can make it anyway". When you do that, I better not be able to find a better slot myself for all of us, and of course when you do that you have implicitly designated the Busy folks as optional.
  8. Finally, the body of the invite.
    1. This has the agenda of the meeting and if applicable the courtesy apologies due to messing up steps 6 & 7.
    2. This should not be the introduction to the meeting, in other words the recipients should not be surprised when they see the invite and go to the body to read it. Notifying them of the meeting takes place via separate email where you explain the purpose and give them a heads up that you'll be sending an invite. That separate email is also your chance to attach documents, don’t do that as part of the invite.
    3. TIP: If you have sent mail about the meeting, you can then go to your sent folder to select the message and click the "Meeting" button (Ctrl+Alt+R). This will populate the body with the necessary background, auto select the mandatory and optional attendees as per the TO/CC line, and have a subject that may be good enough already (or you can tweak it).

Long to write, but very quick to remember and enforce since most of it is common sense and the checklist is driven of the visual cues in the UI you use to send the invite.

How I Record Screencasts

Thu, November 8, 2012, 11:51 AM under AboutPresenting

I get this asked a lot so here is my brain dump on the topic.


A screencast is just a demo that you present to yourself while recording the screen. As such, my advice for clearing your screen for demo purposes and setting up Visual Studio still applies here (adjusting for the fact I wrote those blog posts when I was running Vista and VS2008, not Windows 8 and VS2012).

To see examples of screencasts, watch any of my screencasts on channel9.


  1. If you are a technical presenter, think of when you get best reactions from a developer audience in your sessions: when you are doing demos, of course. Imagine if you could package those alone and share them with folks to watch over and over?
  2. If you have ever gone through a tutorial trying to recreate steps to explore a feature, think how much more helpful it would be if you could watch a video and follow along.
  3. Think of how many folks you "touch" with a conference presentation, and how many more you can reach with an online shorter recording of the demo. If you invest so much of your time for the first type of activity, isn't the second type of activity also worth an investment?
  4. Fact: If you are able to record a screencast of a demo, you will be much better prepared to deliver it in person. In fact lately I will force myself to make a screencast of any demo I need to present live at an upcoming event.
  5. It is also a great backup - if for whatever reason something fails (software, network, etc) during an attempt of a live demo, you can just play the recorded video for the live audience.

There are other reasons (e.g. internal sharing of the latest implemented feature) but the context above is the one within which I create most of my screencasts.

Software & Hardware

I use Camtasia from Tech Smith, version 7.1.1. Microsoft has a variety of options for capturing the screen to video, but I have been using this software for so long now that I have not invested time to explore alternatives…

I also use whatever cheapo headset is near me, but sometimes I get some complaints from some folks about the audio so now I try to remember to use "the good headset". I do not use a web camera as I am not a huge fan of PIP.


First you have to know your technology and demo. Once you think you know it, write down the outline and major steps of the demo. Keep it short 5-20 minutes max. I break that rule sometimes but try not to. The longer the video is the more chances that people will not have the patience to sit through it and the larger the download wmv file ends up being.

Run your demo a few times, timing yourself each time to ensure that you have the planned timing correct, but also to make sure that you are comfortable with what you are going to demo. Unlike with a live audience, there is no live reaction/feedback to steer you, so it can be a bit unnerving at first. It can also lead you to babble too much, so try extra hard to be succinct when demoing/screencasting on your own.

TIP: Before recording, hide your desktop/taskbar clock if it is showing.


To record you start the Camtasia Recorder tool


Configure the settings thought the menus

  • Capture menu to choose custom size or full screen. I try to use full screen and remember to lower the resolution of your screen to as low as possible, e.g. 1024x768 or 1360x768 or something like that.
  • From the Tools -> Options dialog you can choose to record audio and the volume level.
  • Effects menu I typically leave untouched but you should explore and experiment to your liking, e.g. how the mouse pointer is captured, and whether there should be a delay for the recording when you start it.

Once you've configured these settings, typically you just launch this tool and hit the F9 key to start recording.

TIP: As you record, if you ever start to "lose your way" hit F9 again to pause recording, regroup your thoughts and flow, and then hit F9 again to resume.

Finally, hit F10 to stop recording. At that point the video starts playing for you in the recorder. imageThis is where you can preview the video to see that you are happy with it before saving. If you are happy, hit the Save As menu to choose where you want to save the video.



TIP: If you've really lost your way to the extent where you'll need to do some editing, hit F10 to stop recording, save the video and then record some more - you'll be able to stitch the videos together later and this will make it easier for you to delete the parts where you messed up.

TIP: Before you commit to recording the whole demo, every time you should record 5 seconds and preview them to ensure that you are capturing the screen the way you want to and that your audio is still correctly configured and at the right level. Trust me, you do not want to be recording 15 minutes only to find out that you messed up on the configuration somewhere.


To edit the video you launch another Camtasia app, the Camtasia Studio.


  1. File->New Project. File->Save Project and choose location.
  2. File->Import Media and choose the video(s) you saved earlier.
  3. These adds them to the area at the top/middle but not at the timeline at the bottom.
  4. Right click on the video and choose Add to timeline. It will prompt you for the Editing dimensions and I always choose Recording Dimensions.
  5. Do whatever edits you want to do for this video, then add the next video if you have one to stitch and repeat.

In terms of edits there are many options. The simplest is to do nothing, which is the option I did when I first starting doing these in 2006. Nowadays, I typically cut out pieces that I don't like and also lower/mute the audio in other areas and also speed up the video in some areas. A full tutorial on how to do this is beyond the scope of this blog post, but your starting point is to select portions on the timeline and then open the Edit menu at the very top (tip: the context menu doesn't have all options). You can spend hours editing a recording, so don’t lose track of time!

When you are done editing, save again, and you are now ready to Produce.


Production is specific to where you will publish. I've only ever published on channel9, so for that I do the following

  1. File -> Produce and share. This opens a wizard dialog
  2. In the dropdown choose Custom production settings
  3. Hit Next and then choose WMV
  4. Hit Next and keep the default of Camtasia Studio Best Quality and File Size (recommended)
  5. Hit Next and choose Editing dimensions video size
  6. Hit Next, hit Options and you get a dialog. Enter a Title for the project tab and then on the author tab enter the Creator and Homepage. Hit OK
  7. Hit Next. Hit Next again.
  8. Enter a video file name in the Production name textbox and then hit Finish.
  9. Now do other stuff while you wait for the video to be produced and you hear it playing.

After the video is produced watch it to ensure it was produced correctly (e.g. sometimes you get mouse issues) and then you are ready for publishing it.


Follow the instructions of the place where you are going to publish. If you are MSFT internal and want to choose channel9 then contact those folks so they can share their instructions (if you don't know who they are ping me and I'll connect you but they are easy to find in the GAL). For me this involves using a tool to point to the video, choosing a file name (again), choosing an image from the video to display when it is not playing, choosing what output formats I want, and then later on a webpage adding tags, adding a description, and adding a title.

That’s all folks, have fun!

Link instead of Attaching

Tue, October 30, 2012, 09:37 PM under Communication

With email storage not being an issue in many companies (I think I currently have 25GB of storage on my email account, I don’t even think about storage), this encourages bad behaviors such as liberally attaching office documents to emails instead of sharing a link to the document in SharePoint or SkyDrive or some file share etc.

Attaching a file admittedly has its usage scenarios too, but it should not be the default. I thought I'd list the reasons why sharing a link can be better than attaching files directly.

In no particular order:

  1. Better Review. It allows multiple recipients to review the file and their comments are aggregated into a single document. The alternative is everyone having to detach the document, add their comments, then send back to you, and then you have to collate. With the alternative, you also potentially miss out on recipients reading comments from other recipients.
  2. Always up to date. The attachment becomes a fork instead of an always up to date document. For example, you send the email on Thursday, I only open it on Tuesday: between those days you could have made updates that now I am missing because you decided to share an attachment instead of a link.
  3. Better bookmarking. When I need to find that document you shared, you are forcing me to search through my email (I may not even be running outlook), instead of opening the link which I have bookmarked in my browser or my collection of links in my OneNote or from the recent/pinned links of the office app on my task bar, etc.
  4. Can control access. If someone accidentally or naively forwards your link to someone outside your group/org who you’d prefer not to have access to it, the location of the document can be protected with specific access control.
  5. Can add more recipients. If someone adds people to the email thread in outlook, your attachment doesn't get re-attached - instead, the person added is left without the attachment unless someone remembers to re-attach it. If it was a link, they are immediately caught up without further actions.
  6. Enable Discovery. If you put it on a share, I may be able to discover other cool stuff that lives alongside that document.
  7. Save on storage. So this doesn't apply to me given my opening statement, but if in your company you do have such limitations, attaching files eats up storage on all recipients accounts and will also get "lost" when those people archive email (and lose completely at some point if they follow the company retention policy).

Like I said, attachments do have their place, but they should be an explicit choice for explicit reasons rather than the default.

Visual Studio Continued Excitement

Sun, September 23, 2012, 10:45 PM under Personal | VisualStudio

As you know Visual Studio 2012 RTM’d and then became available in August (Soma’s blog posts told you that here and here), and the VS2012 launch was earlier this month (Soma also told you that here). Every time a release of Visual Studio takes place I am very excited, since this has been my development tool of choice for almost my entire career (from many years before I joined Microsoft). I am doubly excited with this release since it is the second version of Visual Studio that I have worked on and contributed major features to, now that I’ve been in the developer division (DevDiv) for over 4 years.

Additionally, I am very excited about the new era that VS2012 starts with VSUpdate for continued customer value: instead of waiting for the next major version of VS to get new features, there is new infrastructure to enable friction-free updates. The first update will ship before the end of this year, and you can read more about it at Brian’s blog post. I also noticed that a CTP of the first quarterly update is available to download here.

In the last two months, the VS2012 family of products we all worked on in DevDiv shipped, coinciding with the end of the Microsoft financial/review year, and naturally followed by a couple of organizational changes (e.g. see Jason’s blog post)… On a personal level, this meant that I was very lucky to have an opportunity present itself to me that I simply could not turn down, so I grabbed it! I’ll still be working on Visual Studio, but not in the Parallel Computing part of the C++ team; instead I will be PM-leading the VS Diagnostics team… Stay tuned for details of what is coming in that space, in the VS updates and in the next major VS release, as I am able to share them…