A bit of Programming!

blog-software-defined-storageI thought it would be fun to do something like this a while ago but never bothered. I had a bit of spare time today so I made myself a little random word generator. Here it is:

function createRandomWord(length) {
var consonants = ‘bcdfghjklmnpqrstvwxyz’,
vowels = ‘aeiou’,
rand = function(limit) {
return Math.floor(Math.random()*limit);
i, word=”, length = parseInt(length,10),
consonants = consonants.split(”),
vowels = vowels.split(”);
for (i=0;i<length/2;i++) {
var randConsonant = consonants[rand(consonants.length)],
randVowel = vowels[rand(vowels.length)];
word += (i===0) ? randConsonant.toUpperCase() : randConsonant;
word += i*2<length-1 ? randVowel : ”;
return word;

alert( createRandomWord(10) );

Anyway, it was just a bit of fun, nothing serious! Please note that it doesn’t create real words, just random combinations of letters, obviously it could create a real word (since it’s random).
Also I thought of reading Java again. I thought it’d be a good idea to get a head start. I downloaded Eclipse and the “Java runtime”, only, of course, to find out that I already had about 10 different Java runtimes already installed.I had absolutely no idea what to create… What can I say? The command-line doesn’t interests me much! Yes, I know pretty much anything can be created with Java, even hardware-accelerated games, but all the beginner-tutorials out there only show you the monotonous command-line drivel.

I have a book ‘Objects first with Java’. I haven’t really got past the first few pages. I’ll tell you something about objects; you’re never going to learn squat about them from tutorials or books. Yeh sure, you’ll get an idea about what they are but you’ll never appreciate the abstraction provided by OO language until you dive in.

The toughest job is to deal with a bad code. Too often a programmer is sure.Approach the code with curiosity and a yearning to understand. Empathy for the person who wrote the code would help too.Their capacity for caring may be directed somewhere other than the whitespace that nestles their parentheses or the seemingly incoherent naming of their variables.

Without empathy you are not going to understand the code, nor how it came about. You will simply sit there vocally festering in your self-appointed superiority.Do you want to understand why there are such rampant GOTOs, such deeply nested switch statements, such obtuse naming. So reading a bit of Software engineering might help that tells us how to write some self explanatory codes.

I might turn this into a monthly post where I share all my latest reading material and other cool links from around the web. Some of the things I was reading on internet these days :


11 thoughts on “A bit of Programming!

  1. I like code that has built in checks & balances, exception handling & error trapping.You may add here an exception handler that checks from a list of profanity & do not generate a random. You may enhance it by having a built-in spell checker so that it gives you an option to generate a random word that is legit!
    And yeah don’t forget to update the documentation every time you make code modification 🙂

    • Thanks for the code ideas, Yes you are correct! There must be exception handling here! I will definitely apply this on all the future codes, I will write (and this one too) ; Yes Documentation is very important, not for others who may read or modify your program but for yourself too. I think the best way to be a perfect coder is to write as much program as you can. And also reading other’s code gives an added advantage to the innovative ideas 🙂

  2. Greetings! I’ve been reading your blog for some time now and finally got the bravery to go ahead and give you a shout out from Dallas Texas! Just wanted to tell you keep up the fantastic job!

  3. Everyone loves what you guys tend to be up too. This type
    of clever work and reporting! Keep up the awesome works
    guys I’ve you guys to my blogroll.

  4. Excellent post. Keep writing such kind of information on your
    blog. Im really impressed by your blog.
    Hi there, You’ve performed a fantastic job. I’ll definitely digg it and in my opinion recommend to my friends.
    I’m confident they’ll be benefited from this web site.

Please Comment Here :

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s