Monday, March 31, 2008

Time To Toon In!

I love this site. I will try to make some more, possibly with less profanity....

Wednesday, March 26, 2008

Building Sandcastles

It's a depressing feeling. You are full of hope as you configure the XML Documentation setting in the project properties (oh yes, this is VS2005).

You were confident about your diligence at filling out the XML Documentation comments, it seemed like everywhere....

Then the horror. Trigger the build, and 582 XML Documentation warnings. Wtf!!!?!

Ok, so 582 edits later, then what?

Oh yes, download the latest CTP of Sandcastle, and start generating documentation. It even makes it look like VS-style yumminess.

Mmmmm.... Forbidden donut....

Yes, but still a few issues to note:

  • The DXROOT environment variable has a path-separator appended to it, which is not usually the custom. The "examples" script assumes there's no path-separator, and as a result, it generates double-path-separator in there.
  • The assembly scanner (which generates the topic list by reflection) wants all dependent assemblies not in the GAC available in the current folder. The build_sandcastle.bat doesn't display this; I only figured it out running it from the command line.
  • There is msbuild support also; I didn't try it. I am leaning toward making a NAnt version, to increase understanding.

Once that all got sorted, I was generating nice CHM files of my hard-typed-in XML Documentation!!

Saturday, March 22, 2008

Don't Float Away

I was doing some background animation recently, which led me into the realm of real numbers, well-known as the bane of programming everywhere.

For the uninitiated (sad to say there are "programmers" that probably know nothing about IEEE number formats), it sucks because only very few numbers can be represented exactly, and this leads us directly into the world of accumulated error and uncertainty.

Big fucking deal! Spare me your gobbledygook! Just let me treat them like integers, and leave me alone...

Take this innocent loop for a quick example. Really. Take it, and paste into your IDE, and run it.


float total = 0.0f;
float incr = 0.005f;
while(true) {
  Console.WriteLine(total);
  total += incr;
}

Now, you desparately want the output of this loop to be [.005,.010,.015,.020,...] but you are going to be disappointed when you run it.

Dude, you are scaring me now....

How can this be? Pretty simple actually. Powers of ten and powers of two don't like each other very much; go back and read the first two paragraphs up there.

In the meantime, all is not lost. A more precise way to do the same thing is the following:


int ix = 0;
float total = 0.0f;
float incr = 0.005f;
while(true) {
  Console.WriteLine(total);
  total = (float)ix*incr;
  ix++;
}

What makes this code more accurate (i.e. better) is the distinct lack of accumulated error. The (floating-point) number for the current iteration is the result of O(1) calculations, where as the other loop's is O(n) calculations.

Of course, this also means that directly testing for equality of two floating-point numbers is also a sticky wicket. Let's just save that for another time....

Thursday, March 20, 2008

What's In A Name?

Everything, pretty much. You are basically no one without one.

So why do we suck so badly at gathering them? I'll give you a hint; it has 20 letters in it, 18 of which are usually glossed over, much like the concept itself: Internationalization, or i18n.

For the ignorant, get your overview here and some more depth here (as always).

Now go ye, and rip out all of those Euro-centric First Name/Last Name fields and fix them. What to do with the database columns you are storing them in, is another problem/post.

Thursday, March 6, 2008

Ping

Just making an entry to keep everyone alive....

Disclaimer

Look, this is humor, so put away the flame-thrower! Just have a laugh and go on your merry way....