Monday, March 16, 2009

Hotmail R.I.P. (1996-2009)

Well not dead yet, but might as well be.

I have been using Hotmail since 1998, and have been using it till yesterday. As of today, I am proud to say that I am completely Hotmail-free. I am a pure GMail-er, all 100%.

There is no doubt that GMail has had far superior features as compared to Hotmail or Yahoo mail, two of the most popular free providers. So what took me so long to make the switch? Two things...

  • Old emails in Hotmail
  • Inability to mass update my email addresses without causing inconvenience, both to me and to others

I had previously posted (10 Indispensable 'GMail IMAP With Outlook' Hidden Features) a way to import files using GMail's IMAP service. But there was no way to import mails from Hotmail, well none until recently. Microsoft recently opened POP3 access to all Hotmail accounts (see gHacks).

So lets see what needs to be done for the move ...

  1. Open Settings > Accounts
  2. Click on 'Add a mail account you own'
  3. Enter the following details...
  4. Save

That's it, it should now import you Hotmail mail. Import one folder at a time and label them accordingly. Also GMail will let you reply to mail from Hotmail with either your Hotmail address or your GMail address. This ensures that people can continue sending mail to Hotmail or if you desire, to you GMail account from that point on.

Here are the settings in text form...

  • Incoming Server: pop3.live.com
  • Incoming Port: 995
  • SSL Encryption: yes

Not used for GMail, but rest of the settings ...

  • Outgoing Server: smtp.live.com
  • Outgoing port: 25 (use port 587 if the default port is not working)
  • Authentication: yes
  • TLS Or SSL: yes

Friday, March 13, 2009

Operator Overloading - Check for null value

Height implements the operators, here is the current implantation of == operator …

public static bool operator ==(Height a, Height b)
{
  return a.CMValue == b.CMValue;
}

#1 – What’s wrong with this code?

What happens if you want to do the following:
Height a = new Height(100);
Height b = null;
a == b

This will result in NullReferenceException … bad bad bad

Ok lets fix this …
public static bool operator ==(Height a, Height b)
{
  if( a == null && b == null) return true;
  if( a == null || b == null) return false;
  return a.CMValue == b.CMValue;
}

#2 – What’s wrong with this code?

Do you see the recursiveness here?
a == null will call the same implementation, resulting in NullReferenceException … bad bad bad

Ok lets fix this…
public static bool operator ==(Height a, Height b)
{
  object _a = (object)a, _b = (object)b;
  if (_a == null && _b == null) return true;
  if (_a == null || _b == null) return false;
  return a.CMValue == b.CMValue;
}

By converting a and b to objects, we are using object’s implementation of the == operator, thus avoiding a recursive call.