Posts

Showing posts from September, 2008

Interesting article on famous programmers

In a bit of a break from my usual posts I read an interesting article on the breakdown of 200 famous programmers . It would appear most have only worked on 1 project and are male. I was surprised to see .45% are transsexual and only 2.7% are women. I know IT/Programming is heavily male but that blew my mind. Also only 1 project? I think a lot of these guys get into a specialty and then don't do anything else for a while. Anyway a bit of an interesting read.

C# tricky ternary operator

C# has a way of letting you shorten up those short little if else statements into one line of code. It's called the ternary operator . Take the following code if something is meets our matching criteria set a value, else set another value. I've written a lot of these in my time as a coder. So let's assume we have some integer we're using, we want to set a string based on that value. We know it needs to be in one of two ranges. We could write an if then else like below: String result = String.Empty; if( someInterger < 100 ) { result = "Less than a hundred"; } else { result = "Over a hundred"; } With the ternary operator you can shorten it down to one line: String result = someInteger < 100 ? "Less than a hundred" : "More than a hundred"; Now some might argue it's less readable and I agree to an extent but if you try it a few times you will find yourself writing a lot less small if/else blocks. You...