Posts

Magic

Wizard Warlock Sorcerer Mage Several words describing people who can use magic... even though none of them ever existed. Right...

Too many people

Overcrowding is a common fear these days, just like global warming and other similar crap. I just thought I'd save here a quick calculation to put things in perspective. Living area for a single person: 100 m^2 (this would make it 400 m^2 for a 4-people family) Number of people you can fit in a km^2: 10,000 (because 1 km^2 = 1 million m^2) Land area of the Earth: 148 million km^2 (see Wikipedia ) Say only a fifth of that area is available for people, that would be 30 million km^2. Multiplied by 10,000 this gives us 300 billion people. 300 billion people. With no many-stories buildings, no overcrowding a la Asimov's fiction (how on Earth could he estimate only 40 billion people for Trantor I cannot imagine) and no food problems ('cause we have four fifths of the land area for that - in fact, even if we remove 30% of the total area as desert it still leaves us with 70 million km^2 for animals and crops). One other thing - what the overcrowding gang never mention is this: on...

Non-nullable reference types in C#

C# 1.0 has non-nullable value types (an int variable must always have a valid int value, it cannot be null) and nullable reference types (a string variable can be null). C# 2.0 added nullable value types (an int? variable - note the "?" - can be null). There are unfortunately no non-nullable reference types (a string variable which can never be null). Patrick Smacchia has a summary of a possible notation and also of the issues that could appear. However, until Microsoft decides to add non-nullable reference types, there's a way of doing the same thing with a somewhat more complicated notation. using  System;      namespace  Extensions   {      public   struct  NotNull<T> where T :  class      {        public   readonly  T value;           public  NotNull(T arg)   ...

Structure of Object-Oriented systems

Image
Objects are state machines Real-life entities have state. Your checking account has an amount of money; your car has a mileage, a gas level, a speed and so on. Objects in an application should also have a state and a set of operations that can manipulate that state. (You can change the color of your car or add money to your checking account; you cannot do the opposite.) That being said, we normally want to hide the state and expose operations because it reduces coupling, which in turn reduces the "brittleness" of the whole system. Tell, don't ask Objects shouldn't have getters and setters; this is sometimes called the "tell, don't ask" principle . There are two cases where getters appear to be necessary: Asking an object for some information and then deciding what how to change the state of the same object. This code could be a fragment of a ping-pong game: if  (ball.Y < 0 || ball.Y > MAX_Y)     ball.SpeedY = ball.Sp...

It's all Bram Cohen's fault

Charles Petzold on why he doesn't sell as many books as he used to : (Undoubtedly another factor contributing to crummy book sales is BitTorrent, but that's so painful an issue I can barely bring myself to discuss it.) This is so much bullshit. Every idiot who comes up with this excuse should be required to pay a zillion bucks for a lecture by Eric Flint. The simple fact is that if a well-paid US computer programmer finds it cheaper to spend a few hours looking for a book torrent on the 'net and downloading it, then you're doing something really wrong. Where is the link to the ebook variant, Charles? Put it on the freaking web for 10 bucks and you'll have removed any incentive to look for a free version. Anyone still doing that would never have bought the paper version of your book anyway. (I paid $25 for The Tomes of Delphi and another $50, if I remember correctly, for shipping.) Another problem, of course - as Eric points out - is that most people never know a...

Copyright considered harmful

Like that's any news coming from me :) However, I just found this page - Unofficial Honorverse Mod in which (at the bottom) a Chris Roensch explains how his company cannot allow fans to create a free Homeworld mod based on the Honorverse because it would dilute their "intellectual property" rights (whoever invented this phrase should be shot) for their upcoming movies and games based on the same universe. Of course, it will came as no great surprise that no such games and movies have been produced since the end of 2005... and I'm willing to bet that movies, at least, never will. (Not to mention that I'm also quite certain that any games that will be produced officially will suck big time. They usually do.) So, another thing that does NOT get created because of the so-called IP rights. Yay for progress.

TDD, or not TDD?

I'm pretty convinced that TDD (or better yet, BDD ) is the way to go. As usual when I get to this stage, I no longer care a lot to discuss the issue. However, I just hit on an interesting article ... one that I find particularly weird. Ravi's point appears to be that TDD is rather useless... and / or that Peter Norvig is a much better programmer than Ron Jeffries. The thing is, as I said here I managed to solve the whole thing in about 8 hours total. Worse, I only did that once I started with a consistent test-first approach, my previous 3 or 4 attempts ended in failure. So. While I have a huge ego (not so huge not to accept Peter Norvig as a better programmer than me though), I have strong doubts that I'm a better programmer than Ron Jeffries. I think that Vlad's article hits on part of a problem: discovering an algorithm using TDD is at least difficult, if not impossible - and TDD was not meant for that. I also think that Ron simply gave up - in fact, I also did tha...