• Monthly Archives
  • July 2013
  • 22 Posts

How to sort collections of custom types in C#

I’ve recently created a program which sorts collections of custom types quite extensively and i thought i’d share the standard method of doing this. When i first started designing my program, i honestly thought it would be quite a pain sorting these collections but i was pleasantly surprised, as usual by the .NET framework, that there are built in shortcuts.

How do i love thee? Let me count the ways.

How do I love thee? Let me count the ways. I love thee to the depth and breadth and height My soul can reach, when feeling out of sight For the ends of Being and ideal Grace. I love thee to the level of every day’s Most quiet need, by sun and candle-light. I love thee freely, as men strive for Right; I love thee purely, as they turn from Praise. I love thee with a passion put to use In my old griefs, and with my childhood’s faith. I love thee with a love I seemed to lose With my lost saints, I love thee with the breath, Smiles, tears, of all my life! and, if God choose, I shall but love thee better after death.

Elizabeth Barrett Browning

What is it about programming? What is that thing that keeps me coming back for more? Why do i spend countless lonely hours tapping away at my keyboard into the small hours of the morning?

Is ‘Linux is only free if your time has no value’ still valid?

EDIT: This is now an old post and my opinion on Linux has changed a great deal over the years. While I agree this viewpoint had some merit a few years ago, the enormous effort by the open source community to make Linux great has generally succeeded. So for the record, this article no longer represents my views on Linux and should be viewed in a historical context.

This is the part where I start getting hate mail from people, and cheerleading messages telling me to take a look at it again, because it’s so much better now. I understand. I’ll take your word for it. And when the time comes to replace the O2 I have today, maybe my next machine will run Linux. But as we all know, Linux is only free if your time has no value, and I find that my time is better spent doing things other than the endless moving-target-upgrade dance.

Jamie Zawinski

The above quote comes from a post made by a programmer called Jamie Zawinski back in1998. It’s a quote aimed squarely at the user unfriendliness of Linux and at the amount of time you need to understand and configure a computer using Linux to get stuff done. Of course this was a long time ago and Linux, in its many different guises (distros), has made a lot of progress, so is this quote still valid?

Hey, stop ruining my work!

Recently a friend of mine ask me to design and create a small website for their fledgling business. Although slightly weary of creating such websites, he was a good friend so i agreed to do it free of charge. The business was something i am not familiar with and while nothing to do with technology i approached the project with enthusiasm and proceeded to gather information from him as i would any other client.

Now, this is what puts me off creating such websites: the information gathering stage. At first i asked him what do you want the site to do for you? He didn’t really know. So i asked him what content should it contain? He wasn’t sure. Not too surprising though i guess because he wasn’t technically minded and never owned a website before, so i suggested i should come up with something to start with then use that as a base to build on and amend as needed.

JavaScript – The Good Parts

This is a Google Tech Talk which everyone who’s using Javascript should watch. In this video Douglas Crockford explains the good and bad sides to Javascript and highlights very good tips for Javascript development.

JavaScript is a language with more than its share of bad parts. It went from non-existence to global adoption in an alarmingly short period of time. It never had an interval in the lab when it could be tried out and polished. JavaScript has some extraordinarily good parts. In JavaScript there is a beautiful, highly expressive language that is buried under a steaming pile of good intentions and blunders. The best nature of JavaScript was so effectively hidden that for many years the prevailing opinion of JavaScript was that it was an unsightly, incompetent abomination. This session will expose the goodness in JavaScript, an outstanding dynamic programming language. Within the language is an elegant subset that is vastly superior to the language as a whole, being more reliable, readable and maintainable.

Douglas Crockford

Enumerations in C, the good, the bad and the ugly

I’ve started to brush up on my C programming and learn the language properly. So, after reading through a chapter in the famous White Bible, i’ve come to the conclusion that C enumerations are pretty bad.

C enumerations have a nice syntax and they are really handy when defining a range of constants with unique int values, but, and here’s the big issue, they are not type checked against a particular named enum, they are only checked that they are an int! Take this code: