## Binary Search Trees Are Cool

I was going through some old programming projects from when I went back to Olympic College for 2 quarters last year. I found a project from Advanced C (CMPTR 225) where we had built a program implementing a binary search tree for an address book. I went a little overboard and even included a rebalancing algorithm.

Anyway, I've uploaded the project in a .ZIP file, and it's in the Code section and can be found here.

## A Couple of Things I Just Learned About C# - Part 2

Alright. Time for round 2. This time I've found a couple of things I actually really like about C#, and one more thing I find mildly annoying.

Let's start off positive, and simple:

### The '@' String Literal.

With the @ String Literal, you can disable special character parsing in a given string. Example: Escaping slashes in a Windows directory path sucks, and if you miss one, it can totally screw you over without necessarily being immediately visible:

string filepath = "c:\\path\\to\\important\\text\\file.txt";

If you prepend the string with @, you lose the ability to input special characters in that single string, but you save a lot of typing:

string filepath = @"c:\path\to\important\text\file.txt";

Now, on to something annoying:

### Data Collection Member Naming Inconsistencies

This one really bugs me. Some things, like Arrays, for instance, have a Length property that tells you how many items it contains:

string[] names = {"Max", "Mike"};
int name_count = names.Length;

Now. On the other hand, things called DataCollections do not HAVE a "Length" property for this purpose. They use a different name:

/* This example assumes you have added a DataGridView called
* dataGridView1 to your form with 2 columns.
*/
this.dataGridView1.Rows.Add(new string[] { "1", "Arnold" });
this.dataGridView1.Rows.Add(new string[] { "2", "Brainy" });
int row_count = this.dataGridView.Rows.Count;

Now, I know some of you must be thinking "That's really not so bad." Well, take this for example. Basic arrays use Length. However, a somewhat more confusing situation exists, and it isn't actually any more complex an example!

System.Collections.ArrayList stuff = new System.Collections.ArrayList();
int stuff_length = stuff.Count;


What?! Yeah, that's right. It says it's an array... but it doesn't have Length, it has Count. Potentially frustrating, but it's mostly just inconsistent design.

And finally, one more nice thing about C#:

### Property Procedures

Property Procedures are an extremely efficient way of implementing mutators and accessors (aka setters and getters):

class DemoClass {
private string _data;
public string data {
get { return _name; }
set { _data = value; }
}
}


Now, this example doesn't really serve much purpose other than to show the syntax of the property procedures. In the end, implemented like this, it behaves exactly like if you had just declared public string data;. I find it to be a very efficient looking implementation.

Typically, you would use this to validate input, limit access, or both. Or, you can omit either the get or set clause to allow only one way access. You can even declare get and set as private or protected to restrict access.

## Oops!

So I just realized a few minutes ago that the captchas for the comment form weren't working! Apparently I had forgotten to compile in freetype support when I built PHP 5.3.2. Anyway, that's fixed now, so comment away!

## Content Storm - Code

The 'Code' section is now in place. It has been graced with one code snippet so far, PHP Hexlify. EDIT: A second code snippit: TimeIntervalHelper v1.0 I expect to add more useful code snippets over time.

Additionally, the site is now using SEF URLs. Since the site is now essentially feature complete, I figured this would be a good moment to implement friendly URLs. So far everything seems to be in order regarding the new URLs, however, please let me know if you find any problems with it. I'd greatly appreciate it.

## Content Storm - Music

The "Music" section is now back in action. About half of the previously available tracks are there. I have deemed the other half unacceptable, and thus will be re-recorded and re-released.

Before that happens, however, the "Code" section still needs to be completed. That will happen either tomorrow or Wednesday, and then re-recording will begin in earnest. Feel free, as well, to make requests. Eventually, I plan to add a request form. For the time being, just comment requests on this or any other relevant blog post.

Oh, and don't forget to check the Music section out by clicking the link on the navbar to the right!