The Coding Monkey

Tuesday, December 27, 2005

Never Put "Bible" In the Title of Your Book

Among various other gift cards I received this Christmas, I got one from Barnes & Noble. I love books of all kinds... so I stopped by a store yesterday to peruse through the isles. As it turns out, I didn't buy any, but I did spend a while looking. My stack of unread books is still pretty high, and so I decided I needed to shorten the stack before I bought more. I always go through the section of the store that has programming books to see if anything catches my eye. The store at Mayfair has unfortunately decided to shrink that section more and more every time I go... I guess I'll be getting even more of my technical books from Amazon now.

Anyway... one title caught my eye in particular... and not because I was interested in the subject matter anymore: Standard C++ Bible. I don't write C++ anymore, though I used to do a lot of it. What caught my eye was the title. I would never buy a book... ever... that had "Bible" in the title... except maybe one. As far as technical books go... if you have to put "Bible" in the title, then it isn't one. Technical bibles are known as such because of their good information and well known authors. They're the types of books that are known simply by their author's last names. This is the C++ bible... and "Bible" is not in the title.

This actually reminds of a Friend's episode (as sadly many things do). It's the one where Monica has recently broken up with Richard, and gets a message on her answering machine from him, but doesn't know if it's old or new. She ends up leaving a message on his machine and ends it with "I'm breezy". Joey then tells her... "Hey, you can't say you're breezy. That totally negates the breezy!". This may in fact be the only time in the history of the show where Joey used the word "negates"... and is very much out of character for him. Anyway... I digress. You can't put "Bible" in the title of the book... it totally negates the holiness of your writing.

Friday, December 23, 2005

Pet Peeve

White papers available for download as an exe. Why? It's a white paper. Make it available immediately in one of the many many formats for transferring documents. What about Word format, HTML, PDF... any of those. If it's huge... zip it up! I don't want to have to run an exe just to get a doc. Who knows what else is in there. Besides, who doesn't have zip on their computer these days? The more steps you make me go through to actually read the paper, the less likely I am to read it... I'm just saying.

One More Reason I Liked My Alma Mater

You won't find any of these courses where I went to school. They actually offer courses and labs having to do with... you know... your degree program. Here's some of my favorites from the list of the Most Bizarre College Courses:

The Unbearable Whiteness of Barbie: Race and Popular Culture in the United States at Occidental College in California explores ways "which scientific racism has been put to use in the making of Barbie [and] to an interpretation of the film The Matrix as a Marxist critique of capitalism."
...
Alfred University's Nip, Tuck, Perm, Pierce, and Tattoo: Adventures with Embodied Culture, mostly made up of women, encourages students to think about the meaning behind "teeth whitening, tanning, shaving, and hair dyeing." Special projects include visiting a tattoo-and-piercing studio and watching Arnold Schwarzenegger’s bodybuilding film, Pumping Iron.

I wonder if students will think those classes were worthwhile when they have to figure out how to pay off their student loans?

Wednesday, December 14, 2005

Go For the Take Aways

Yesterday I went to the local Visual Studio Launch Event in Brookfield. Everyone was there for one thing... the free copies of software. Specifically they gave away full versions of Visual Studio 2005 Standard, and SQL Server 2005 Standard (not time expiring versions). The talk they gave was... well... about what you'd expect. I thought I'd share a few impressions.

First of all, I know its a difficult thing to do one of these so well, as to not have any complaints from anyone. Whidbey included so many new features, that trying to talk about all of them in 4 hours, in sufficient depth to satisfy everyone, is simply impossible. But that doesn't mean I can't complain does it?

One of the first things that they talked about was Visual Studio Team System. This includes functionality of Team Foundation Server (bug tracking, source code control, and project management), as well as developer tools like unit testing, and architecture tools. This is not a new market space. Products have existed for a long time in these areas from companies like Rational (now owned by IBM), PVCS (now owned by Serena), NUnit, and many many more. The funniest part about the talk was how they pretended like they were innovating here, instead of simply duplicating existing products. Of course the reality too is that there simply aren't as many features in their versions, as with the products they aim to replace. The only advantage is the tighter integration with Visual Studio proper.

Next up was the discussion of new functionality in ASP.NET. He blew a lot of time here. Unfortunately for him, he tried to move off of the script, and there were several times where it didn't work for him. It wasn't his fault at all, as he was trying to write code on the fly, and naturally had errors occur, some of which weren't easily debugged. There were some interesting things shown here, and I suppose I was disappointed that so much time was spent here mostly because I'm a Windows Forms developer. But even I do some web development, so I could appreciate what was being shown.

Then came the Windows Forms demonstration. It sucked. First of all, he spent about half and hour showing a couple custom controls he wrote, which didn't use any new features in .NET 2.0. They were written completely with functionality available in 1.0. So what was the point? He did show two new controls that are available in .NET 2.0, but it was a very short demo. Finally, he demonstrated Click Once Deployment, which was intriguing, and fairly worthwhile.

Overall, I think they made the mistake of showing too much code. Really, in a 4 hour demonstration, you can't show any code that's not trivial, so why bother with really trivial code at all? Why not concentrate on a higher level discussion of new features? Just my two cents. Like I said in the beginning, I was really just there for the take aways.

Tuesday, December 06, 2005

Even More Pronunciation

I had this discussion with someone at work a few days ago. If you're a programmer, then you've seen the built-in data type char. So how do you pronounce that? I think most people pronounce it one of two ways:

Char as in char broiled. In other words, pronounce it phonetically, which is how I pronounce it.

Car as in automobile. This one kind of annoys me. The thinking is that char is short for character, so you should pronounce the ch as a hard k. But if that's your thinking, then shouldn't you pronounce it like...

Care as in care package. After all, character is pronounced care-acter. But if you're going to go that far, then why not...

Chair? Maybe I'm taking this too far, after all... nobody says chair-acter.

Now then, my mom is really good at English, but if I asked her, then she'd say...

Shar... because her name is Charlotte which is pronounced Sharlotte, and her nickname is Char (pronounced Shar).

Isn't it funny how such a simple topic can take on a life of its own?

Saturday, December 03, 2005

Did You Know You Could Do That?

I promised a couple weeks ago that I'd start a series where I would discuss little known features of the .NET Framework. In this first installment, I'll be talking about including resources in a .NET assembly. To be honest, I don't know why people don't use this feature more often than they do. Resources contained within binaries is not a new feature introduced in .NET after all... they've been the basis of Windows programming since before Petzold wrote his first book. What is newer in .NET however is the variety of files that you can include as a resource, and also the ease with which you can gain access to them. When I say variety... I mean variety. You can include literally any type of file as a resource that you'd like to. How's that for flexible?

So before I go into how you do this... let's answer another basic question. Why would you want to include a file as a resource? There are several reasons why you might want to which I'll go over (and this is by no means exhaustive).

Internationalization: .NET includes an easy way to internationalize your text, and part of that is having separate assemblies for each locale. But what if you have more than just string constants that need to be translated? Perhaps you have images that include text in the image, or you have a rich text file that you want to display that needs to be translated. Those can be included inline in the translated assembly, allowing you to make use of .NET's ability to load the correct version of your assembly for the locale of the system, and get at the correct translated resource.

Ease of Installation and Safety: Some of the more annoying parts of writing software is making sure that you get all the proper components on the target system, and then having to deal with those files being removed when they shouldn't. By including required files that don't need to be modified (like an XML schema) in your assembly, you reduce the number of files that need be copied to the target system, and you also don't have to worry about those files going missing later. There's nothing worse than dealing with people who decide they want to clear up 50 KB on a computer that has a 50 GB hard drive by removing "unnecessary" files.

Default Configurations: This is one of my favorite uses. I generally don't like to use the .NET config file mechanism for storing configuration settings, because I find it ugly. It's really not that hard to roll your own simpler XML scheme, and sometimes you might be required not to use the .NET config file mechanism(as I have been in the past). But what happens if that settings file does go missing? You'd like to still include a set of default settings... so how do you do it? Well, one possibility is to sprinkle those defaults across all your classes in the form of constants, and lines of code in constructors. The problem with that solution is that its a pain in the butt to go around and find them later if they need to change. Wouldn't it be smarter to have two versions of your configuration file? One that has the defaults, and one that has the user settings? That way you can load your defaults using the code that you wrote to read in user settings, and then they're also all centralized. As you'll see in a second, you can put that defaults file in the assembly as a resource, and then read it just like any other file later.

So how is this done? Well, the first thing you want to do is make sure that you have your project's default namespace setup correctly. The Visual Studio Compiler uses this to set the namespace of your resource in the assembly, which is what you'll use to gain access to it.



Then, add each file that you want to be a resource to your project, and for each one set it's build action to embedded resource. In this example, the file has to be be referenced as "SummerCampProductions.ResourceDemo.Config.xml". If you add a folder to your project, then the folder name will be used as a child namespace, and any files under that will be in that child namespace.



That's it... that's all there is to adding a file as a resource to your assembly. But now how do you gain access to it in your code? Here is some example code that checks for a configuration file in the executable directory, and if it's missing, loads the defaults from an embedded resource file.

Stream SettingsStream = null;
try
{
   string UserSettings = Path.Combine( Environment.CurrentDirectory, "Config.xml" );
   SettingsStream = new FileStream( UserSettings, FileMode.Open, FileAccess.Read );
}
catch
{
   string DefaultSettings = "SummerCampProductions.ResourceDemo.Config.xml";
   SettingsStream = Assembly.GetEntryAssembly().GetManifestResourceStream( DefaultSettings );
}

XmlDocument SettingsDoc = new XmlDocument();
SettingsDoc.Load( SettingsStream );

// Load Settings Here

Thursday, December 01, 2005

Blog Rolling

I've added Gooey Bugs to my Microsoft Blogroll on the right side. It's a tips and tricks blog by Jim Gries over in the Visual Studio team, and has some great debugging tricks and feature overviews, including new features in Visual Studio 2005 like Object IDs which are freaking cool!