Say Hello to Dit Lexaragez
/I've been writing the next lab assignment for our programming course. We are creating a Bank, rather like the one in the Yellow Book. Anyhoo, we've got as far as making some test data for the system that we are building. Demonstrations of massive account databases are all very well, but it is best if they have more than two or three accounts in them.
It's best if all the fake accounts have different names, so I started playing with ways to make names programatically. I ended up using a method based on a very popular daytime TV show in the UK. See if you can guess the name of the show.
My method works because names are frequently made up of the sequence “consonant – vowel –consonant” – for example “Rob”. All my method does is pick a random consonant, followed by a random vowel and then a random consonant. For longer names it just adds more vowel-consonant pairs on the end.
static Random testRand = new Random(1); static string vowels = "aeiou"; static string consonants = "bcdfghjklmnprstvwxz"; static string pickRandomLetter(string input) { return input[testRand.Next(input.Length)].ToString(); } static string makeTestName (int parts) { string result = pickRandomLetter(consonants).ToUpper(); for (int i=0; i < parts; i=i+1) { result = result + pickRandomLetter(vowels); result = result + pickRandomLetter(consonants); } return result; } static string makeFullTestName() { return makeTestName(testRand.Next(1, 4)) + " " + makeTestName(testRand.Next(2, 6)); }
This is the C# that we are using for the lab. I fired it up and the first name that came out was "Dit Lexaragez" which I think is a great name. The names have a vaguely "off-planet" feel that I really like. I've suggested that people might like to fiddle with the letter sequences to modulate how much of each letter you get (you probably don't really want 'z' to appear as frequently as 't' and maybe allow some names to start and/or end with vowels.
I love it when a really simple bit of code produces really interesting behaviours.