Archive for April, 2008

April 4th, 2008

Web design pet peeves (number 352 in a series of 23238434)

Posted in Coding / Development, The Web by Diggory

Email addresses are not case-sensitive

I hit this *so* many times and it always drives me mad. Here’s the thing: email addresses are not case-sensistive. i.e. FOO@.BAR.COM is the same as foo@bar.com and FoO@bAr.CoM

Web designers always seem to forget this though – and it’s incredibly irritating, especially if you have a browser which has some form of ‘remember my details and auto-complete them’ function.

I can understand why it happens though, and here’s why. As a coder you think of things in terms of types and logic.

Types: Number-types are generally either floats (floating point numbers: 1.2, 3.1415, etc…) or integers (whole numbers 1, 2, 100232 etc…). Computers ‘think’ of numbers differently depending on whether they are whole number or not. Bits of text are often thought of as ‘strings’ (‘strings’ of characters) – think of a string of pearls where each pearl is a character.

Logic: Coders use logic to define behaviour in code – they set down rules for the computer to follow. i.e. ‘if this thing over here is equal to that thing over there then do this other thing.’ Many of these logical statements are combined to create behaviours that make-up software products – from your mobile phone, to this weblog, to your TV.

Anyway – back to the point – humans forget that computers see things in different ways – the human brain with it’s amazing ability for language and symbol analysis sees ‘Hello’ as having the same meaning as ‘hello’, whereas to a computer these two strings are completely different, so to a computer the correct response to the question ” is ‘Hello’ equal to ‘hello’ ” is “No.” Normally that’s fine in logic terms – the two strings are not identical – but when it comes to email addresses – this logic lets us down. It doesn’t matter what case the letters are, what we should be asking the computer is “does this string that the user gave *spell* the same as the string we are using as a reference?”

Of course a clever coder will take the case of the letters out of the equation by using a function which makes the two strings to compare both upper-case before it checks them for equality – so however the user types the email address (as long as it’s spelled correctly), the logic will come back and say – “yes – these two email addresses are the same.” This is such a common task that there are always (I assume) ready-made functions available to the coder in any language to turn a string into an upper-case string.

It just takes a little thought to make sure that you apply that function when checking email addressees. You’d be surprised how often it doesn’t happen though…

The same thing happens in other problem domains – e.g. usernames – my router has an admin account which allows me to configure it – let’s call it ‘admin’. If I use ‘Admin’ it fails to authenticate me. Usernames should not be case-sensitive, whereas passwords should.

Web servers / filenames are another case: http://www.foo.com/badger/ should be the same as http://www.foo.com/BADGER/ – Mac OS computers treat these two the same – UNIX machines don’t.

To humans, most strings are not case-sensitive, whereas to computers they are. Coders should think about this more often. Alas it’s easy for them to be caught out, since we don’t think like computers, and computers are ruthlessly logical and unforgiving when it comes to rules (which is why they work). They’re a bit like traffic wardens in that respect.

Rant over….