# Sunday, 21 September 2008

One of the most mind-clearing features of C++, C#, VB, and their ilk are exceptions. Rather than constantly checking a cascading series of return values, looking for false, -1, null, and whatever other error-signalling values you made up on the day you were writing the code, you can write relatively clean and neat code knowing that catastrophic errors (we have no more memory, the file you just chose from a list no longer exists, apparently I'm not allowed to write to the hard drive at all) will be handled. In C++, the "unwinding the stack" aspect of exceptions, with the memory cleanup and destructor-calling done for you, is a big part of writing clean code that is also memory-leak-free.

But have you ever thought about what happens to half-constructed things when an exception goes off? That is, when the constructor throws an exception before its work is done? I have had people tell me "oh simple, never throw an exception in a constructor." Wrong! A major motivation for the existence of exceptions is the existence of methods (like constructors) that don't have a return value to check. The rule you're half-remembering is "never throw an exception in a destructor" and the reason for that is to prevent weirdness when an exception triggers an unwinding and some destructors and then one of them throws another exception.

So what does happen to a half constructed object when an exception is thrown in the constructor? Who better to ask than Herb Sutter? He shows how C++, C#, and Java all answer this question... and his commenters toss in some other languages too.

Kate

Sunday, 21 September 2008 08:17:44 (Eastern Daylight Time, UTC-04:00)  #    Comments [2]
# Saturday, 20 September 2008

Others have noticed this (Alexey Govorin, for example) but I tend to forget about it until just before I'm going into a meeting and feel that an export of work items would be helpful. I have some queries set up in VSTS that include the bug description. Here's how they look in Visual Studio.

Description is quite a long field, and when I open the query in Excel (didn't know you could do that? Right click the query in the Team Explorer pane) I see this:

Some, but not all, of the Descriptions are coming up all ####. Now this is what Excel does when something is too long for the column width. So it makes sense to look at things like widening the column, turning on Wrap Text, and the like. But the quickest thing that works for me is this: select the column. On the ribbon, drop down the formatting choice and choose Number. Not Text, which is what I would expect, but Number. Presto - I see all my Description entries.

Why does this work? I have no idea. But I hope this helps someone else.

Kate

Saturday, 20 September 2008 08:02:17 (Eastern Daylight Time, UTC-04:00)  #    Comments [0]
# Friday, 19 September 2008

Microsoft Canada is trying something different this fall and winter. A paid conference featuring material from this year's TechEd USA, delivered by excellent local speakers and coming to a city near you. Some cities have two day events, others a single day.

  • Toronto, October 29th and 30th
  • Montreal, November 6th and 7th
  • Ottawa, November 27th
  • Winnipeg, December 4th
  • Calgary, December 10th and 11th
  • Halifax, December 17th
  • Vancouver, January 21st and 22nd

What will the talks be like? What will it cost? Will there be cool swag? The web site doesn't really say right now, but I've been told the talks will be actual TechEd talks, the speakers will be industry leaders (my friends and colleagues, maybe me if we can make the dates work), and there will be 5 or so tracks, meaning over 30 sessions, so something for everybody. The early bird discounts will be substantial, so watch that web site for updates!

Kate

Friday, 19 September 2008 16:54:42 (Eastern Daylight Time, UTC-04:00)  #    Comments [0]
# Thursday, 18 September 2008

Some time ago a prospect called me to ask if I could help him solve a really frustrating problem. He had some software that was working and that he had delivered to dozens of clients, but sometimes it froze. It featured a lot of timers and he thought the problem was that one of them stopped firing, but he wasn't really sure. Could I do a code review for him and find where he had been stupid or sloppy to cause this problem?

So this is an intriguing concurrency problem, because multiple overlapping timers are not something you can definitively test, so I answered him "sure, send me the code." He sent it along and unfortunately it was really quite well written. That's unfortunate because I couldn't point to some obviously sloppy or stupid code and say "fix this and all will be well." We gave him some advice about how to gather problem information from users when they reported that one of the clock/timers "froze", and wished him luck.

Months later he came back, saying that it was a distinguishable subset of his clients that were having the problem, and please could we look again? He sent us the source code, as well as a deploy package that had gone to the most recent client to experience the problem. At first, we couldn't build his source code, because he had a whole pile of custom controls and funny license files and so on. So while we were waiting for him to send us things, we played with the executable. We couldn't make it misbehave. If repro cases don't come easily I usually switch to reading the code and imagining what could cause what I'm seeing, but when that doesn't work I'm back to trying for a repro. We were hoping it was having some sort of leak - memory, handles, something like that - which was freezing or hanging it. Repeated perusals of the source code convinced us the timers were a red herring, leaving mystery leaks as our best guess.

Did you know you can get Task Manager to show you more than just memory and CPU usage for your applications? On the View menu, choose Select Columns:

Then check off what you want, such as Handles and GDI Objects. Now watch while the application runs:

In this case, the deployed application didn't have a memory or handle leak, but it did seem to have a GDI Objects leak. The count kept going up, and never went down. We even discovered a way to make it go up -- there were buttons in the UI forming a toolbar of sorts, and they had a special effect as you moused over them and moused off again. Every time we caused the special effect to fire, the GDI Objects count would go up. This is the sort of thing that's impossible for developers to repro, because we don't idly wave our mouse back and forth along a toolbar wondering which button we should click. We test for like 5 minutes and say "looks ok to me." But we had been told that the freezes generally only happened when the application ran longer than usual - 4 hours rather than the usual 2 or 3. So we were hoping for some sort of leak that generally had no consequence, but could kill you if you waited long enough. So having learned how to drive the count up, we sat there waving the mouse around and driving it up. When we drove it past 10,000 - the application froze. Yay! Repro!

So we went into the source to reproduce it under the debugger - but the version we built from the source he sent didn't show the same behaviour - the GDI Objects count was well behaved and went up and down a little bit, never getting anywhere near 1,000 never mind 10,000. And interestingly, the source code he had sent us just used regular buttons in that toolbar like area. Aha! I blame the special button.

I asked him, since I didn't have the source for the version that was freezing, to tell me more about the button and where it came from. He told me the name and the URL from which it was downloaded. I went there and got a version number and file name, and confirmed he was running the most recent version available from that site. He also told me that now that I mentioned it, the only folks who'd reported freezing were the folks for whom he'd included the special button. So I knew it had to be the culprit. Time for some searching. Several people claimed that control had a "memory leak" problem. What's more, the developer of the control had released a newer version, which hadn't been mirrored over to the URL our guy found it from.

I told him all this, he went and got the newest version of the control, built the solution, and indeed the GDI count is now well behaved, and no-one has been able to make the application crash, freeze, or hang ever since. (I sat on this story for a few months to be sure.) So there you go, problem solved! I wouldn't have thought it was possible when we started. The moral for me is to use all the tools you have, and to use them fully. This problem was solved with Task Manager, an insistence on trying to reproduce the problem, and Live Search. Phew!

Kate

Thursday, 18 September 2008 16:39:56 (Eastern Daylight Time, UTC-04:00)  #    Comments [0]
# Wednesday, 17 September 2008

A recruiter called me looking for an architect. I would be a good fit for the job if I was available - I have tons of Internet programming experience, architect systems all the time, services and desktop among others, and as for quiet confidence and entrepreneurial spirit, those describe me just fine. But I'm not available. It occurred to me that a reader of my blog might be. So if you're interested, please contact the recruiter. Good luck!

A software firm (30 people) in downtown Toronto is looking for a full-time architect to help build its next generation of Email System.

The organization is a divsion of a large U.S. based firm with a CEO with a track record of successful entrepreneurial start-ups and exits.

The firm develops applications within Microsoft Exchange and requires an architect with the following skills:

  • A high-level design capability as well as the willingness to be hands-on within the development cycle
  • Experience building applications within Microsoft Exchange, using MAPI, Active Directory
  • Experience building applications around Microsoft Outlook
  • Service oriented backend infrastructure
  • SMTP expertise
  • Desktop application and integration development experience

The right person should have a passion for coding and building systems, have quiet confidence as well as an entrepreneurial spirit.

If you are interested, or know of someone that might be appropriate, please contact Mike Fox at mfox@brightlightsinc.com or 416-406-1777.

Kate

Wednesday, 17 September 2008 18:05:25 (Eastern Daylight Time, UTC-04:00)  #    Comments [0]
# Tuesday, 16 September 2008

Here’s a free and useful add on for Office 2007. It enables “save as PDF” from a variety of Office products. Here’s what Save As looks like in Word 2007 now that I have it installed:

No muss, no fuss. No products that make my computer hang :-).

Kate

Tuesday, 16 September 2008 07:23:38 (Eastern Daylight Time, UTC-04:00)  #    Comments [0]
# Monday, 15 September 2008

At the moment I only have one fall speaking commitment settled and it’s one of my favourites - Tech Ed Developers Europe. Barcelona will be warm, both in the temperature sense and the personal interaction sense (though I do predict exposure to pocket-picking, bag-lifting, and other forms of theft once again). The attendees will be energetic and appreciative. The other speakers will be fun to hang around with. The ancillary events will be fun fun fun.

My topics are the Vista Bridge, and some new C++ features. We’re still working on the abstracts and titles, so I’ll post an update when they’re locked.

See you there!

Monday, 15 September 2008 17:06:49 (Eastern Daylight Time, UTC-04:00)  #    Comments [0]
# Sunday, 14 September 2008

This year we FINALLY get a PDC. I have been looking forward to it for a long time, but booked my attendance and my flights during one of this year’s blogging hiatuses (hiati?). If you are responsible for any kind of strategy or planning, if you are starting a project that will take several years to finish and you want to use the latest technology while you’re building it, or if you just love making software and can’t wait to see what’s next, then the PDC is for you.

http://www.microsoftpdc.com/

It’s the last week of October, in Los Angeles (the only thing about it I don’t really like) and it will just cram your brain with information you actually can’t use to write code quite yet -- but that you really need to plan your own roadmap over the next few years. If you want to know something about a product that is already shipped (say, Visual Studio 2008) then this is not the conference for you. Even if your area of interest is software that is mostly written, maybe has a CTP out already, and will be released during 2008, then again, PDC is not really going to help you. PDC is about stuff that is just starting now. PDC is about getting a big headstart on those who waited till a product was released or a public beta was available. Here’s the list using their own keywords (the numbers are how many sessions are on that topic)

Ad Platform [2]
ADO.NET [3]
ASP.NET [9]
Cloud Services [27]
Dynamics CRM [3]
Entity Framework [3]
Expression [2]
HPC [1]
Hyper-V [2]
Identity [8]
IIS [2]
Internet Explorer [2]
Languages [8]
LINQ [4]
Live Mesh [5]
Live Platform [11]
Office [4]
Oslo [6]
Parallelism [7]
SharePoint [3]
Silverlight [11]
SQL Server [14]
SQL Server Data Services [6]
Sync Framework [2]
TFS [3]
Unified Communications [3]
Velocity [1]
Virtual Earth [1]
Visual Studio [13]
VSTS [6]
WCF [6]
WF [8]
Windows 7 [5]
Windows Home Server [2]
Windows Mobile [2]
Windows Server [1]
WMI [1]
WPF [5]
XNA [1]

Wow - 27 sessions on cloud stuff? Pay attention.

I also chose a random session so you could get an idea of the level of conversation PDC is for:

Unified Communications: Futures

Kyle Marsh, Chris Mayo

In this session we unveil the future of Microsoft Unified Communications (UC) technologies. Be among the first to see the UC roadmap, watch the new features in action, and walk though the code that makes it all possible. Come see how you can deliver breakthrough applications by embedding rich presence, build click-to-call features including voice and video, create communication workflows using speech and IM, and integrate Microsoft Exchange 2007 features and data.

Tags: Advanced, Unified Communications  

This is one of the few conferences in the world that I get myself to (that's right, my own money) as an attendee. I'm not there to speak, work a booth, or be on a panel. I'm there to learn, and you should be too. See you there!

Kate

Sunday, 14 September 2008 11:39:29 (Eastern Daylight Time, UTC-04:00)  #    Comments [0]