C# Generic Lists

I remember the many frustrating hours I spent in C and C++ dealing with arrays. I remember the nights hunting down the cause of a bug, only to realize it was the result of exceeding my array bounds. I remember having to redefine and copy arrays when I wanted to change the number of elements in the array, because in C, array length is fixed.

When I learned about linked lists, it got better. Rather than allocating a specific chunk of memory, like a static array did, linked lists are much more flexible because each element simply contains a memory pointer to the next one. This is very flexible, because you can add, remove, or change the nodes in a linked list quite easily.

However, accessing the elements of a linked list is more complicated than accessing an array. In an array, if you wanted to loop through and output all the elements of an array, you could do the following:

for (int i=0; i < sizeof(arrMyArray) / sizeof(int); i++) {
cout << arrMyArray[i] << endl;

A linked list is not much more complicated:

for (LinkedList objNode = objMyLinkedList; objNode != null; objNode = objMyLinkedList->Next) {
cout << objMyLinkedList.m_Data << endl;

However, the linked list really showed its limitation when trying to access elements randomly. You can do the following with a C array, but not a linked list:

cout << arrMyArray[27];

Thankfully, in C++, the standard template library introduced vectors, which are a kind of dynamic array. The stl::vector saved me a lot of headaches once I learned how to use it.

In C#, you can use what are called generic lists, which are like C++ vectors. As I was programming my GEDCOM importer last night, I really came to appreciate generic lists. They have all the conveniences of the C array and the C++ vector. You can create them dynamically, but you can also access them just like an array. They’re really easy to use, too:

using System.Collections.Generic;

List intNumbers = new List();


for (int i = 0; i < intNumbers.Count; i++) {
Console.WriteLine(intNumbers[i] + “\n”);

I’ve Turned Off Anonymous Comments

If you want to post a comment to my blog, you’ll have to log in now. I was receiving several abusive comments from an anonymous user. Seriously, I am running this obscure little blog, getting 4 visitors per day, and one of them keeps posting garbage in the comments.

I think this is representative of a general lack of politeness and civility on the web. An ordinary person wouldn’t shout vitriolic insults to someone’s face, but when you give him a computer, an AOL account, and anonymity, suddenly he becomes an obnoxious jerk.

There’s No Accounting for Taste

Yesterday, a client of mine asked me what I thought of his website. I hadn’t quite expected the question, and therefore hadn’t formulated a real opinion of it, so I had to come up with a critique of it on the fly. This was a challenge for me because I had to quickly evaluate the website’s strengths and weaknesses.

Together, we navigated through the website, and I explained elements I liked and elements I disliked. For some of these opinions, I was able to back them up with good reasons: the fonts need to be consistent throughout the site, the color scheme should match, gratuitous Flash should be avoided, and so on. However, with other features, I was only able to say that I liked or disliked them, but couldn’t articulate why.

The client, in good humor, said I was using the “Boyd K. Packer” approach. Years ago, when he had been working for the Ensign magazine, Boyd K. Packer would point out elements in the magazine’s design which he liked or disliked, but wouldn’t offer a reason. This drove the designers crazy. Apparently, I was using the same approach in reviewing the website.

After the meeting, I kept thinking about it. Why do some things look visually appealing and others not? How do you explain why a sunset is beautiful, or why a garbage heap is ugly? How do you explain why a bad design is bad? It feels to me like trying to explain to someone how to swallow or how to breathe. Then again, maybe it’s just a matter of personal style. After all, there’s no accounting for taste.

The Caves and Civilizations of Draconika

So, I have been spending a bit of my time lately working on a web-based game, The Caves and Civilizations of Draconika. You can see that it is still in its very early stages of development, but here is a screen shot:

It is a wargame, much like Risk or Diplomacy. Each player will start out with a single territory, and will try to become a great civilization through conquest, diplomacy, and trade.

I am using MySQL for the database, PHP for the server-side coding, and Flash for parts of the user interface, including the main map. Although my forte is ASP.NET development, I’m using the LAMP (Linux, Apache, MySQL, and PHP) stack for this project because:

  1. I’ll be hosting this on a Linux server.
  2. I do Windows/IIS/ASP.NET/SQL Server every day at work, so this is a good way to help develop some of my other abilities.
  3. I’d like to do some fairly involved integration with VBulletin, which is written in PHP.

Now, I’m using Flash for the map and some other parts of the UI, because it can do some pretty cool effects, and it’s faster/smoother than dynamic image generation. Every other web-based wargame I’ve found on the internet looks darn ugly, and I thought it would be cool if I could make one that looks totally awesome.

One neat thing I’m doing with the project is using AJAX and web services to get information from the server dynamically, so you don’t have to refresh the page all the time.

So, keep reading for more news about this project over the next several months. Thanks for reading!

All About Unicorns Launched

For those of you who have enjoyed my website about dragons, you may be interested to know that I recently launched a similar website about unicorns, called All About Unicorns. It is still very small, but I hope to grow it over the next few months as I find the time. It currently only has 100 images in its gallery, but I have over 1,000 that I will be adding after I make some improvements to the image gallery script.

Home Sick; Website Updates

I woke up feeling quite sick this morning, so I didn’t go to work or school. I like to joke with my wife that I am getting “sympathy” sickness.

So, instead of just staying in bed all day, I got around to improving this website some. I made the pages look better and more consistent. I like this new look better; I hope everyone else does, too.

Chelsea went to the baby doctor for the first time today. She hasn’t come back yet, but I hope that she and the baby are going to be healthy for the duration of her gestation. Also, we got a home inspection done on the house we itnend to buy in Kaysville. It had some big plumbing problems, so we’re going to have to negitiate with the sellers to see what can be done to repair them.

Queer Eye and Too Many Logins

On a recent episode of Queer Eye for the Straight Guy, my company’s software product was featured. It was only shown for fifteen seconds or so, and mentioned but briefly. It seemed like an important milestone, though, as the company continues to grow and be used by more people learning to read.

Also, we were formally assigned to our game prototype projects. I think of it as a bit of a contest, myself. I made up some graphics for the game, and even lent my voice talent to its narration. One of our programmers will be making the game in Flash, another in Authorware, and I will be doing a version in C++. We each have a maximum of 20 hours we can spend on the project. If I finish mine early, I am going to try to port it to the Macintosh, just to prove it can be done. (And to show off.)

I was thinking today about how everyone has so many different logins for so many different computer programs and websites. It is simply too much to ask of an ordinary user–or any user, for that matter. It seems to me that login and authentication ought to be included as part of the fundamental protocols of the Internet, you know, so you could login once and be recognized everywhere.

I think we are a long way off from this goal, though. Microsoft tried to do it with its MSN Passport, but I think that failed because they charge outrageous licensing fees to websites who want to use it. With some of the vibrations going around now about reworking the Internet, such as the Internet 2 project, I hope this will be part of it. Not only would it make life simpler for computer users, but I think it would also help to cut down on spam.