Monday, 2 June 2008

Why return isn't evil?

We know that GOTO is the root of all evil (OK, GOTO and premature optimization). However, why return is different? For instance, if you write in Java...

boolean equals(Object o) {

if (!o instanceof MyClass.class)
return false;
....
}

it is salt, and spice and everything nice, even though it is unstructured. Not only is it OK, it is recommended.
I think I have an idea. In this case you are not breaking the structure of the code. You are just shortcutting a huge else; it is the short for of "else do the rest of the stuff, clear local variables and return a value". However, this doesn't apply for continue of break; In both cases they are unstructed and mean: "continue with an unnamed block of code, but leave variables as they are", which is exactly what GOTO does.

Update Jun 4, 4:04: A colleague reminded me the amazing number of WTFs that can be produced just with returns. I have seen them and they can be as ugly as GOTOs; I mainly meant those clear returns that are nested only one or two levels deep.

Add to Technorati Favorites

Thursday, 8 May 2008

The world worst traveller: beating my own records.

This time I had to travel from Dublin to Valencia, changing planes in Madrid. When I arrive to my second flight, I am elated to find out that the flight has only 4 passengers in an ATR 72 (with capacity for 68 people). I sit down, after double and triple checking it is the right flight (since there is another Iberia flight traveling at exactly the same time to Valencia). I arrive to Valencia quite fast, even before the planned time (I guess a couple of tons make a difference to such an small airplane), just to find out that my luggage isn't there! There were more crew-members than pieces of luggage, but they still manage to delay mine. They sent it to my hotel the following day, no harm done, but it is amazing they can screw up moving 3 suitcases!
Add to Technorati Favorites

Tuesday, 22 April 2008

Airline prices (or how to make a convoluted system not even operators can understand)

A few months ago I bought a plane ticket and I needed only one way; however, it was cheaper (in absolute terms, not relative or anything fancy) if I bought a return ticket.
As if that weren't enough nonsense, now I had an extra leg I am not going to use, so I'd like to change it to some date when I can effectively use it. After listening to music for 30 minutes the phone operator tells me that changing the date, since it exceeds the maximum stay, is more expensive than buying a one way ticket (and I guess much more than a return).
I think Google will never make a search engine for plane rates. Indexing the web: easy.
Finding the cheapest rate from A to B: hard (heck, I guess it is NP-complete)

Add to Technorati Favorites

Saturday, 5 April 2008

This is the kind of people you find in Google...

So, the standard way of doing thing in the music business is:
-You publish crap
-Your sales suffer because you publish crap
-Some of your suffering customers download your stuff even though it is not worth the electricity it takes to download them
-You sue your customers

Now, the new EMI CIO, ex Googler, says that suing your customers is not a good idea, even though the full music industry is going for it. Again this is what I like about working in Google: nothing less than a full-scale revolution is good enough

Add to Technorati Favorites

Saturday, 29 March 2008

Travelling salesman with N processors

XKCD applies one more... I have to say that in this case the problem is slightly changed, since it is no longer the travelling salesman, but N customers going to the distribution office, but heck, the joke is still good.

Add to Technorati Favorites

Tuesday, 25 March 2008

Blackberrying and eating gum

I am getting tired of famous magazines plagiarizing my blog. In this case, Time blatantly copied my post about Google reducing my lifespan. I hope my formula for profits works this time... I have a big time lawyer: his last client was SCO!

Add to Technorati Favorites

Monday, 24 March 2008

How to update Netgear WPN824

In this post I just want to single out a something from my previous post... If you have a Netgear WPN824, the auto-update feature doesn't work. You have to download the firmware image from the website and apply it.
Of course, applying a firmware upgrade is not for the faint of heart. It is one of those cases when reading the manual and following precautions is useful. You have to do it with the device firmly connected to the wall, in a sunny day, without cats, dogs or children around, praying to your favorite deity (in my case, Steve Jobs) that everything goes well.
In a related note, it reminds me of something I learned in my previous jobs. Electric companies don't apply patches to their EMS or other important systems in rainy or windy days, just in case there is a power failure.

Add to Technorati Favorites