Stringly Typed Booleans

I’m getting rather hacked off seeing boolean properties typed as strings. Stringly typed is a phrase I learnt off a post from the excellent Coding Horror blog and it describes a phenomena whereby properties that are of a specific type, e.g. Boolean, Date, int, are stored needlessly as strings.

I’m working on a website that communicates with a money laundering service to check whether an individual is “bad” or not. Individuals can pass the test, but importantly it is possible to pass the test with some warning flags raised. If any of the warning flags are raised then an email should be sent off to compliance for them to do…whatever it is they do. Fair enough right?

The warning flags are obviously booleans. There was either a warning raised or there wasn’t – there are no two ways about it (no pun intended). In the serialized response, the warning flags are encoded as “Yes” or “No”…which is understandable. Now, upon receiving the response, it is parsed and turned into an internal representation. This is where things get really weird. The programmer that coded the object that stores the response from the service has decided to encode the warnings as strings, initialised to “”. Which is totally fucking bonkers.


Well, now our boolean warnings aren’t really booleans – they have WAY more than two possible values and the meaning of these values is subjective. One may consider “”, null, “No” as false, but could conceivably also consider “false” or “0″. We get the same sort of problem with true – “Yes”, “1″, “true” and then we get a whole load of unknown values which is every other possible string in the world. Which might be considered to be true.

So how the hell can any number of programmers work on this piece of code without introducing errors because of differing definitions of truthy and falsey values? Well, they can’t. To illustrate the problem further, even loosely typed languages differ in their boolean coercion, for example JavaScript and PHP:

if("0") alert('Opposite day!');

if("0") echo 'Opposite day!';

JavaScript considers “0″ true but PHP considers it false. Personally I think JavaScript is “right” here, but as I said before, it is totally subjective.

The icing on the cake is of course the extra code you have to write to check the truthy or falsey string values. Something along the lines of “if x is not null and not empty and not the word No then it is probably true…probably”, which would otherwise have been coded as “if x then true” if x was a boolean – which is orders of magnitude shorter.

Of course, there are some bat shit crazy strongly typed languages that allow you to assign null to a Boolean, but that is a different story altogether.

Email signatures rant

I hate long email signatures, they are one of the most unnecessary, pointless, wasteful and irritating things I can think of. And what the hell does it even tell me? I mean perhaps, if it was the first email I ever sent to someone outside of my workplace I’d want to write my name, company and perhaps my website address in my signature, but if we work at the same company, or have known each other for 18 years, wtf are you sending me this information for?

Who are the idiots who write their email address in their signature? I know what your email address is! You just emailed me!…and there are TWO, yes two SMTP headers that perform this job – “from” and “reply-to”. Stop it. Stop it now.

Another major annoyance is that they get in the way of quoted text in email threads, so I end up with 500 lines of signature for every 2 to 3 lines of useful text. If you hadn’t already guessed, this makes reading emails really difficult…and I don’t even like reading easy to read emails.

But what really grates is the people who have the audacity to tell me (in green text) to consider the environment and not print the email, when, if I did print it, their signature would take up over 90% of the used paper and ink anyway. Not to mention the additional bandwidth and thus electricity they’re using by sending such a massive amount of text down the line EVERY TIME they send an email. YOU consider the environment and remove that text from your signature.

That leads nicely on to multipart MIME HTML emails. HTML emails are usually sent by your email client as two versions: a plain text version (so recipients who have mail clients that can’t display HTML can read the message) and a HTML version. So every time someone sends out a HTML email they actually send a duplication of the same content. The worst part being that 99.9% of emails sent to me do not need to be HTML and are often only sent as HTML to accommodate visual layout of information in the signature. So stop sending me HTML emails unless it is truly necessary! You’re wasting my bandwidth.

I want my Snow Leopard functionality back!

Lion’s Mission Control is the closest thing I have to Snow Leopard’s Spaces. Generally, I’m fine with Lion. I’m used to the reverse scrolling and can just about deal with not knowing what I can and can’t scroll (although that is starting to grate), but the following things really affect me as they are “killer features” that I now don’t have:

  • No see “all windows in all spaces”. In Snow Leopard I had bottom left as my spaces hot corner and bottom right as my all windows hot corner. What was awesome was that I could trigger spaces at the bottom left, and then trigger all windows at bottom right – which meant I could see all windows in all spaces! Mission Control shows me all windows in the current desktop, but not all windows in other desktops…grrr
  • No moving windows between spaces/desktops. In Snow Leopard I used to be able to move windows between spaces, I cannot, in Lion, move windows between desktops…double grrr
  • No rearranging desktops in the order I want them. Also note that “Automatically rearrange spaces based on most recent use” is completely useless. I really don’t want Lion to move my furniture around…how am I ever going to find stuff if it isn’t left in the place I put it?


I started using chrome as my main browser. What was holding me back was that the webkit developer tools for a long time just weren’t as good as Firebug. Now they are almost on a par. So I’ve been using Chrome as my main web browser for coming up to two months now and for the most part it has been a fantastic experience. Chrome is just lightning fast, from startup to rendering to javascript performance. I don’t have any benchmarks, but everything just feels really "light".

This could be because I’m coming from Firefox with three plugins installed: Firebug, Web Developer Toolbar and Adblock Plus…but I get the feeling that if I disabled the Web Developer Toolbar and Adblock Plus, Firefox still wouldn’t feel as light. Anyway, this isn’t why I started the blog post. I really wanted to vent a couple of frustrations I have with the browser. Seemingly minor frustrations that could probably be fixed really easily. Here they are:

  1. I can’t change the default font or page background colour or if I can, I can’t find where I do it. I change the default font and background colour from black to dark red and from white to grey respectively so that when I build websites I remember to set a default font and background colour in my reset
  2. It is really hard to save a 1×1 pixel image from a website to my desktop. I have to pinpoint the exact pixel on the screen and right click on it. I haven’t figured out an easier way of doing this…if there even is one
  3. When saving an image using the network tab of the developer tools the filename becomes "download" and _not_ the filename of the image I am saving
  4. Lastly, no out-of-the-box RSS support. I really miss it, and I love Firefox’s implementation of it in the bookmarks bar. N.B. I realise there is a plugin.

VB.NET and project imports

Much to my displeasure, I’ve recently inherited an ASP.NET 1.1 website. After a bit of a wrestle they eventually handed over the source code (Why are .NET developers so precious over their code?). Unfortunately they didn’t hand over the Visual Studio project or solution files as well.

Fair enough, I can easily create a new solution and import all the code…no problem. Except there were problems, 104 of them. If you’ve used Visual Studio before you’re likely to know what that means. It means: a shit load of errors, except I’m only going to show you 104 of them.

The kind of stuff I was getting was:

Type 'Control' is not defined.

…and there were no error messages for missing imports. I scratched my head for ages until I thought of the notion of “automatic imports”. What if, these guys have somehow specified a set of imports that get appended automatically to each file…which I haven’t defined?

Turns out, you friggin can do exactly that. In Visual Studio 2003 it is: Right click on project > properties > project properties > imports.

Who the hell thought of that? Surely it is a completely ludicrous idea! It means that if the code gets separated from the project (which is exactly what happened) it won’t work correctly. Not only that, but how the hell am I supposed to know if MyClassName belongs to com.companyX.package or com.companyY.package???

So I’m just totally guessing at the moment, and I’m down to 18 errors. Man I hope it eventually runs.

IE7 onclick and :active state

Curiously, if you add an onclick event to an anchor in IE7, the anchor remains in the CSS :active state regardless of whether the javascript returns true or false. It’ll stay in this state untill you click on another element on the page.


<!DOCTYPE html>
	<style type="text/css">
		a:active {
	<a href="#" onclick="javascript:return true;">Click me</a>

MooTools Depender, Safari, etags and 412 Precondition Failed

* This replaces the default MooTools more Depender.request function to use
* HTTP "get" rather than "post".
* When sending requests for files via the depender, I was finding that Safari
* wasn't getting and re-evaluating them the second time I visited the page.
* This was because an etag was sent with each script.
* Safari responds to etags properly and adds "If-None-Match" and
* "If-Modified-Since" headers to another request for the same file. This makes
* Apache respond with a 412 status (Precondition Failed) as it should do for
* "post" requests (according to RFC 2616).
* Unfortunately Safari doesn't then deal with the 412 as it does with a 304
* (Not Modified). It doesn't grab what it has in the cache and put it in the
* response, it gives you nothing.
* For "get" requests, Apache has to respond with a 304, or 200 or whatever, but
* not 412. So we change the request method so we don't have to deal with 412.
Depender.request = function(url, callback){
    new Request.JSON({
        url: url,
        secure: false,
        onSuccess: callback,

IE7 and HTTP

Why doesn’t IE7 assume I want to use HTTP as my communications protocol? IE6 seemed to be able to, FF, Opera and Safari seems to be able to. For pete’s sake, you’re a web browser! What other bloody protocol do you normally use? If I were ever to type anything in the address bar, and I didn’t specify http://, ftp://, file:// etc., the chances are that, in actual fact, I really, actually, meant, http://, surely?

When will M$ drop support for IE6?

Whilst working with IE6 recently, ha, sorry I mean against IE6 – I found that a number of times I was asking (read: wishing) when support for this horrendous browser would be dropped. According to, support could be dropped when mainstream support for XP is dropped. Wouldn’t that be great? But hang on, isn’t everyone doing their best to avoid upgrading to Vista, hoping that M$ doesn’t drop support, or even stop allowing new PCs to be shipped with it until Windows 7? It seems that we have a bit of a conflict of interest here, meaning I don’t think there is a way of getting rid of IE6 whilst keeping XP – which is annoying, to say the least.

adobe and case sensitivity

Adobe why? I formatted my Mac as case sensitive HFS+ because, well, lets face it, capital letters are different from lower case letters. Imagine how disappointed I felt when I got round to installing Flash on my case sensitive filesystem. It didn’t help that it was the last thing I did after installing leopard and setting up my files and applications, since there doesn’t seem to be a way of converting case sensitive HFS+ to case insensitive HFS+.

Luckily for me, Adobe wrote a helpful tech note on this issue, and by ‘helpful’ I actually mean jaw droppingly unhelpful.

Was I asking for trouble?