Thursday, January 29, 2004

Anonymous Exception Catching

I was going through the FlexWiki code the other day, and I saw this block of code:


catch (FormatException ex)
{
    ex.ToString(); // shut up compiler;
}


I've seen this before: you know an exception is going to be thrown, and you also know that it's safe to ignore it. (You should think twice about doing this, but sometimes it's unavoidable.) And that annoying little call to ToString() winds up in there because otherwise the compiler pitches a warning about there being an unreferenced local variable. Although it's only a warning, and could in theory just be ignored, many build systems wisely compile their code with the warning level set to maxiumum, which would actually turn this into a compilation error.


The code often gets written this way because developers don't realize that you can safely do this:


catch (FormatException)
{
}


Notice that there's no exception variable. This will compile just fine, and it does exactly the same thing the previous code does - silently throws the exception away. Only now we don't have that confusing extra line of code in there, and the compiler won't complain about unused variables.


I should point out that there actually is one case where you might want to leave that line of code in. If you want to be able to view the exception while debugging, it's convenient to have a variable to examine in the debugger. However, in that case, I would recommend using this code instead:


catch (FormatException ex)
{
    Debug.WriteLine(ex.ToString());
}


This has the advantage that under a Debug build, you can still set a breakpoint and examine the exception. However, because System.Diagnostics.Debug.WriteLine is marked with the [Conditional(”Debug”)] attribute, it will not be compiled at all under a Release build - it'll be like that line of code isn't even there.


This is a slick little bit of compiler magic that you can take advantage of in your own code to write functions that disappear from your Release builds. Check out the documentation on the Conditional attribute for more information.

Wednesday, January 28, 2004

Yukon Issues Solved

With a little help from my friends (thanks Tim and Brian), I got my Yukon problems sorted out. The fundamental issue was that I had forgotten to install the Yukon test certificate before installing Yukon itself. Apparently, one of the pieces is signed with this, and the signature check fails during installation if the certificate hasn't been installed. So after re-running the install, everything appears to be working well.


The biggest mystery, though, is that all my .NET 1.1 stuff started working before I got Yukon running again. And I'm not sure what I did, although I suspect removing .NET 1.1 paths from the LIB environment variable might have been the key. Unfortunately, I wasn't very scientific in my desperate flailing. I'm just happy it works.

Monday, January 26, 2004

Win32 to .NET API Mapping

The inestimable Tim Tabor posted this on the WinTech Off-Topic Mailing List today:



His summary: “Wow”. I concur.

Direct3D "Creating a Mesh" Tutorial Available

What have I been working on lately? Well, I plan to explain in a bit more detail later, but this last week I wrote another Direct3D tutorial. It's about how to manually create a Direct3D Mesh, and you can find it here. As a bonus, I also briefly discuss z-bias and wireframe rendering.


Looking back, I've been writing these for just over a year - I published my first one on January 20th, 2003. Since there are now 15 in the series, that means I've been doing better than one a month. On top of that, I also did a short DirectSound tutorial series. Which, when I thought about it, surprised me: I felt like I've been slacking on these lately, but that rate is better than what you get from a regular magazine column.


But enough tooting my own horn - enjoy!

Another Band on the Runtime

I was listening to Progged Radio today. It's my favorite “radio” station - it's hard to find the obscure branch of music I like (progressive metal).


Anyway, a song came on, and I had to laugh. It was the title track from “Marathon” by SAGA, and the chorus goes something like this:


It takes time to get to avalon
That's why we're on this marathon


Full lyrics here.


I think someone from the Avalon team needs to pick up this album for those long nights of coding.

Yukon D'oh!

While I was out in Seattle last week, I stopped off at MSDN to talk to some people about getting going on the project I'll be working on. One of the exciting pieces is that we're going to be using some really bleeding-edge stuff, like Yukon and Whidbey. So it was convenient for me to grab the interim builds of these products, since that's we're going to develop against. In fact, we expect to track the product teams pretty closely, updating our development environment frequently with new builds.


Like I said, this is exciting for nerds like us. But like most things, it's a tradeoff; we knew that it was going to cause us some pain. This weekend I encountered the first pangs. In the middle of installing Yukon, I got an error message to the effect of “MDAC does not meet the Windows Logo requirements. It will not be installed.” Then the whole install rolled back.


In and of itself, that doesn't sound too bad, but in the wake of it, neither the .NET 1.1 C# compiler nor any version of ASP.NET works on that machine. Joy. Hopefully we'll get it sorted out soon. In the meantime, I guess I can do command-line compiles of my side projects (more about those later) with the Whidbey C# compiler. Not the greatest setup, but enough to give me some confidence before I do a check-in.

Friday, January 23, 2004

Back in the MSDN Saddle Again

I'm in Seattle this week, visiting my wife's relatives. As long as I was here, I paid a visit to the Microsoft Campus, specifically to building 5. I needed to sign some paperwork so I can get started working on the MSDN re-architecture again. I've been off the project for about six months, but now it's really spinning up again - the work we did before was only the beginning.


What does this mean for you, dear reader? Well, since we're going to be doing a lot of cool stuff at MSDN, and since I have clearance to blog, you can expect to hear about it here. For example, MSDN is making the extremely bold move of implementing using pre-release versions Whidbey and Yukon. I've always admired this sort of “eat your own dogfood” philosophy, and now I actually get to be paid to play with the stuff. Woohoo!

Monday, January 19, 2004

The single most interesting technology I've heard about in a long time



RNA interference - seems like this has
potential to cure everything from cancer to the common cold...literally.



 



(You'll need to register to get onto the site, unfortunately, but it looks like they
won't send you anything you don't want if you don't want it. Also seems like they'll
take a fake email address, since they don't confirm the one you provide. Besides,
it’s Technology Review, so it’s MIT, so what’s to worry about? :)
)



 


Sunday, January 18, 2004

Physiology of Software Development

I was wondering today: what would a doctor think if he was watching my stats while I was programming? Would my heart rate go way down? Way up? Would an EEG look really strange?


I wonder for two reasons:



  1. When programming, I often enter a weird state of super concentration, where I'm aware of little going on around me, and the code in front of me ceases to be a sequence of characters and takes on a much more abstract realization. I'm not claiming this as a unique experience - I think this is a common experience for many developers.

  2. Sometimes when I'm writing code, I get really hot. I have a thermometer next to my desk, and the temperature rarely varies by more than one degree. So as a guy that's generally quite cold, getting warm is a sign that something is unusual. I haven't linked it to one particular activity yet (e.g. debugging, design, etc.), usually because I'm too distracted by being in state #1.

A quick Google didn't turn up anything on studies in this area, but I have to wonder if there's been some work done here.

Friday, January 16, 2004

Big Brother Jackpot

My friend Rob Engberg and I had a long conversation this morning about privacy and transparency in society. It was pretty interesting: he's sort of a libertarian, and I'm sort of a liberal, so in the end I think we wound up mostly disagreeing over whether society (my position) or the individual (his position) should kick your ass if you spy on me. :)


Anyway, the upshot of all of it was him seeing what he could figure out (just based on looking on the web) about the nondescript building he could see across the street. It turns out the answer is, “Rather a lot.” While this is hardly surprising to people that use Google on a regular basis, I still found this link to be a surprisingly large font of information about all sorts of stuff. Rob jokingly calls it the “Big Brother Jackpot”.

Color-Coded Terrorist Threat Levels



I know I’ve posted about Bruce
Schneier’s CryptoGram newsletter
before…but it’s just so good. Here’s another
great article about what’s wrong with the color-coded threat levels (Yellow,
Orange, etc.) that the US Government has been using. To sum up: they’re worthless.
Much as I would like to blame this on President Bush, I’m not going to. His
approval ratings and the tiny amount of public outcry over the massive sell-off of
personal liberties for the (mostly false) perception of increased security point out
that things like this are a consequence of a society-wide fear, not the actions of
one man or one administration.



As usual, the only real antidote to fear is education, in this case about what security
really means. In other words, if you haven’t already signed up for Crypto-Gram,
do!


Tuesday, January 13, 2004

TheServerSide.net Debuts


Ted Neward – a fellow DevelopMentor instructor – has taken a new job. He is the new editor in chief of TheServerSide.net (RSS here), a brand-new website that promises to focus on building enterprise applications in .NET. TheServerSide.net is operated by The Middleware Company, the same people that brought us TheServerSide.com, a well-known Java enterprise development website. Obviously, there’s an opportunity for a lot of synergy there.


Ted invited me and a few others to have a sneak peak at the website last night, and it looks pretty good! It’ll be a site for people to post .NET enterprise development news, but Ted’s going to be filtering everything to keep the quality high. In addition to news, they’re going to have streaming video interviews (the first with Don Box), discussion forums, and case studies. I find the last particularly interesting, because it seems like there’s a general shortage of “Here’s how you do this stuff in the real world” type information.


They’re also soliciting articles for publication, and a couple of mine on broad architectural principles of large-scale system design have been posted. All in all, it looks like it’s going to be a pretty good resource. And Ted is the perfect guy for the job.

Monday, January 12, 2004

EIF Woes

So far, I've been quite happy with Microsoft's Enterprise Instrumentation Framework (EIF). It takes a while to get used to the configuration schema, and there are a fair number of knobs and buttons to twist, but once you get the mental model right the design is actually fairly clean. All the problems I've encountered so far have been mine.


Until now. I recently moved the project I was working on to a load-balanced machine, to test it in that environment. I had a problem, so I did what I usually do: fire up the log viewer I wrote against the EIF reader API to check out the log. And I saw no events.


At first I thought it was configuration - that I might not have set up the remote machine properly. Nope - the trace service (I'm using the trace service they ship with the project as my event sink) wrote a file, and when I copied that file to my local machine, I was able to view it just fine. Next I thought it might be a bug in my viewer. Nope - the viewer they ship with the product has the same problem.


I whipped out Reflector to decompile the EIF libraries to see if I could find the problem. Unfortunately, TraceLogReader.Read disappears into some native code that they wrote at some point, and the problem pretty much has to be in there.


So basically, at this point, I'm thinking there's a bug in the EIF TraceLogReader.Read method around reading from logfiles on remote machines. Given that the product is supposed to support enterprise applications, this seems almost ludicrous. I'm hoping that I'm missing something - but it doesn't look like it.

Friday, January 9, 2004

The Many Uses of 80GB

On Wednesday, I got the new 80GB hard drive I ordered (only $60!). First of all, it reinforced the wise decision I had made in listening to Brad when he advised that I buy an Antec case with the new computer I got a while back; I always expect to spend two hours on even the simplest of hardware tasks, but I had the thing mounted and running in about 20 minutes…love it!

Anyway, the second drive on my goof-around machine means that Longhorn could finally get installed. Yes, I know that I could run it in a VirtualPC instance, but the machine isn’t particularly beefy, and I’m sort of impatient. Besides, the second drive is going to be my new backup solution…having tried tapes and CDs for years, I’ve come to realize that about the only mechanism that I like for periodic backups is a plain ol’ “make sure it’s in more than one place on disk” sort of arrangement.

It’s not like I need one more thing to play around with right now, but I’m looking forward to checking out all the PDC bits nonetheless.

Wednesday, January 7, 2004

Ian Griffiths On Tap

Ian Griffiths has a new blog. Get the (ugly-ass) HTML here, and the RSS here. Ian is one of the smartest people I know, and the fact that he's a DevelopMentor instructor means he knows how to get the contents of that huge brain into other people's brains in an efficient and painless manner.

Ian is also a prolific writer. This may be aided by the fact that he is also the fastest typist amongst the DevelopMentor instructors. (This is based on a conversation we instructors had last year. Yes, we're huge nerds. Big surprise.) I'm hoping the combination of his knowledge, verbosity, and keyboard proficiency will mean we can count on seeing a lot of good stuff off of his blog. I am very definitely subscribed! [via Kevin Jones]

More on the Theory of Everything...


Early and Adopter wonder about a unification of relational, object-oriented, and XML models:  


To get unification in physics, the primary tool has been the particle accelerator.  Maybe if we slam a SQL and VS box together at 99% of the speed of light, something interesting will happen.  What you learn from a supercollider is that things that are completely different (water and wood) are really made out of the same sub-atomic particles. [Sean 'Early' Campbell & Scott 'Adopter' Swigart's Radio Weblog]


I think the analogy may contain the answer. You see, programming is chemistry, not physics. That is, it’s a fundamentally practical art, rather than a theoretical one. This is the reason that the OO designs of the 90s failed to scale – the OO physicists were smashing two hydrogen atoms together to make helium, but the rest of us wanted a car. It’s hard to make a car out of helium.


My point is that we already know what the subatomic particles are: ones and zeros. There’s an excellent level of conceptual purity there. You can even talk about “atoms” like Streams, Tuples, and Unions – but you still have to do the chemistry to bake up a real system. The problem is that when you start to group those ones and zeros into the higher-order constructs that you need, you wind up with things that have fundamentally incompatible properties – transactions versus distribution, objects versus relational, oil versus water. So I’d have to say I’m with Tim Bray on this one.



NewsGator 2.0 Announced



I’ve been using the Beta of NewsGator 2.0
for a few weeks now, but today the NDA which kept me from talking about it expired.



As usual, the software is rock solid and well thought out – clearly written
by people that know how to make stuff that just works. But my favorite new feature
is the subscriptions synchronization. Now, when I’m at work, I can subscribe
to a new feed, and it’ll also show up in my subscription list at home.
Furthermore, if I read an item at work, it won’t be downloaded when I grab the
news at home – I only get the new stuff. Very cool.


Thursday, January 1, 2004

The Year in Review

Given how much retrospective material we see in the regular media this time of year, I was a bit surprised at the lack of “The Year Iin Review” material there was on the blogscene. That said, here are some personal highlights from 2003.

·        I started this weblog. Here’s my first post. It was Radio at first, then BlogX, then dasBlog, each time vastly improving on the experience. Hopefully there will be a bit less software churn this year.

·        I started my Direct3D tutorial series. Fourteen articles later, it’s easily the most popular thing on the website. It has been fun to get thank you emails from people from around the world – it encourages me to keep going!

·        I wrote the last configuration section handler I’ll ever need. This got a reasonable amount of coverage in the blogosphere, and I still get emails about it from time to time. Of course, these days, I tend to use the CMAB for industrial-strength applications, despite my initial misgivings.  

·        I shifted from doing mostly teaching to doing mostly consulting in 2003…and I’m loving it. Not that there was anything wrong with teaching, but writing real code for a living has been a blast – I’ve learned a lot about things I never would have picked up while preparing to teach in a classroom setting.

·        I got married. Twice. To the same woman both times – one ceremony in Hawaii in March, one in Taiwan in September.

·        I started a new gig at MSDN. At first I couldn’t say much, but eventually the gag was removed. The first phase of the project completed, and I’m off of it right now, but I hope to start up again soon. It’s a really interesting project working with Tim Ewald and some other very smart people.

·        I spent a few months on the no-admin wagon. It was painful, but educational – I highly recommend trying it for as long as you can manage. Of course, I’m off again now – the fact that QuickBooks flat out refuses to run as a regular user was the brick that broke the camel’s back. Still, the lessons remain with me.