Thursday, May 13, 2004

Yet More Direct3D Translations

Uploaded a bunch of stuff this morning:

  • Portuguese translations of my Direct3D slides. Available here. Thanks to Alexandre Lobao, author of  .NET Game Programming with DirectX 9.0.
  • The fifth and sixth installments in the Direct3D tutorial series, en Francais. Thanks to Kershin.
  • The first and second installments in the Direct3D tutorial series, translated into Afrikaans. Thanks to Ernst Kuschke.
  • Also, I noticed that DotNetPro now has a place to read the German articles I wrote (well, I wrote them in English and my friend Marcus translated them) that doesn't require registration.

If you're interested in doing a translation of anything on this site, please contact me. I'd have no problem with you hosting it on your page as long as I get to post it here too. Oh, and if you see a mistake in any of the translations, let me know on that one, too: of all the stuff I posted today, I can only actually read a tiny bit of the French one. :)

Beware File.OpenWrite

I was working on putting some finishing touches on FwDocGen yesterday, when I came across a subtle bug that took the help of Mike Woodring to figure out. FwDocGen is a fairly straightforward wrapper around an XSLT that takes in XML documentation and produces FlexWiki pages that document the classes, namespaces, etc. in your project. The idea is to produce the equivalent of MSDN docs for your class library, but on a wiki instead.


(Side note: FwDocGen is now released in a fairly usable form.)


Anyway, what I was seeing was that the last part of the documentation for a class would show up twice. That is, the docs would list all the methods, properties, etc., and then part of whatever came last would show up again: a little documentation fragment that was completely out of place.


Naturally my first instinct was that I had screwed up the transform and thrown in one too many <xsl:apply-templates /> calls. But everything checked out there, so I was stumped. I saw Mike was online, and since he's preternaturally smart, I pinged him. Within a few minutes, he had said the magic phrase that turned the light bulb on in my head. “Looks like a truncation problem,” he said. And it was.


The fundamental issue was that I was doing something like the following:


FileStream fs = File.OpenWrite(path);


which is a very handy convenience method for opening a file for write access. Unfortunately, as it says right in the docs, this is the equivalent of saying


FileStream fs = FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);


which is most definitely not the same thing. Why not? Because OpenOrCreate, when accessing an existing file, does not nuke out the contents that are already there. So if you have a file whose contents are


ABCDEFG


and you do a File.OpenWrite() on it, and then write “123” into it, you get


123DEFG


instead of just “123”. In other words, the file is not truncated on open. Which is probably not what you want. It certainly explained my problem, though. I'd changed the transform so some of the files were shorter, and when I re-ran the program, it wrote the shorter version over the top of the longer version, leaving the extra garbage at the end.


The fix was dead easy. I just swapped out File.OpenWrite for


FileStream fs = FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);


which works perfectly well. Somewhat confusingly (although it's well-documented), Create still works if the file is already there. But it truncates the file. Thanks Mike!

Wednesday, May 12, 2004

Get An Accountant

My wife and I run our own business. Occasionally, people that are looking to do the same thing will ask me for advice on what to do. My advice is always the same: talk to an accountant.


See, it's not that accountants are particularly necessary for doing things like keeping track of who paid you when: we actually do that ourselves. It's that the tax laws in this country are so unbelievably complex that you can't be an expert in your field and tax law too. Why are the tax laws so important? Because of two things:



  1. Picking the type of company to form (S Corporation, LLC, sole proprietorship, etc.) has a major impact on your tax liability.

  2. Figuring out what is an allowable deductible expense is hard. Getting it right can mean thousands of dollars a year in your pocket and/or your retirement accounts. Getting it wrong can mean an audit at best and jail time at worst.

An accountant is going to cost you, but they should always save you way, way more than you pay them. Talk to a few of them, though. One thing we found out was that there are as many approaches as there are accountants. This is something that is brought home to me by the fact that every time I ask our accountant what I think is a straightforward money question, he says, “Welllll...it depends,” and then goes on to explain what it depends on.


Which is exactly the same answer I give to software architecture questions. :)

Thursday, May 6, 2004

Nifty Autocomplete Tip

Keith Brown sent out this interesting tip today:



You can delete autocomplete items in Office and IE by holding the mouse down on the item that's getting in the way while the autocomplete listbox is down (you can force it to drop down in an empty field by clicking that field a couple times if necessary) and pressing DEL.


I'm loving this feature - I just used it to delete some old addresses from my TO: autocomplete in Outlook.


Obviously, this will come in handy.

Analogies Are Like Busses

I noticed that Brad posted a link to Joel's foreword of Mike's new book. Specifically, he called out this paragraph:



There’s something weird about software development, some mystical quality, that makes all kinds of people think they know how to do it. I’ve worked at dotcom-type companies full of liberal arts majors with no software experience or training who nevertheless were convinced that they knew how to manage software teams and design user interfaces. This is weird, because nobody thinks they know how to remove a burst appendix, or rebuild a car engine, unless they actually know how to do it, but for some reason there are all these people floating around who think they know everything there is to know about software development.


Is this really true? I've said before, people love compare our industry to others and say, “We should be more like that.” But I'd argue that - human nature being a constant - it's more likely that we simply don't see the manifestations of stupidity in other professions. For example: how many of a doctor's patients are people that decided to stop taking their antibiotics because they felt better? Or how many mechanics fix cars that never should even have been driven to the shop? Ask a doctor/mechanic, and you'll probably hear tales of people that never should be allowed to touch a human body/automobile.


It's true that few people will try to remove their own appendix. But few developers will try to write their own TCP/IP stack. Which is to say, since analogies are inherently subjective, you can prove anything you want with them. Show me a quantitatve measure of task complexity, then talk about how people approach software tasks differently...because I'm not convinced that they do.


After all, no matter what field you're in, half of your collegues will be dumber than average. ;)

Wednesday, May 5, 2004

Abstractions Really *Are* Leaky

I was just reading an interesting article over at the Scientific American website about complexity and quantum mechanics, and an analogy hit me between the eyes so hard I had to laugh.


Anyway, I'm not much of a physicist, but here's what I understood: superconductivity is an example of a quantum mechanical effect that exists on a macro scale. This is odd, because quantum effects generally only exist at a very small scale - by the time you get to bigger objects, quantum weirdness goes away. My (admittedly weak) understanding is that this is because the interactions between the tiny pieces sort of “average out” the quantum “smearing”. So, for example, you don't have to worry that I might teleport across the room while you're talking to me, the way you might if we were both electrons.


On to the analogy. When I read that superconductivity was a macro-scale quantum effect, the thought that spang immediately to mind was “Wow, talk about a leaky abstraction!” In other words, here's yet another example of the fact that you can never hide all the details of what's going on. You always have to be able to strip back the model to get to a lower level...living in blissful ignorance is only a part-time luxury.