Gareth Lennox

Lack of updates

Yes, I am still around ๐Ÿ™‚

We are currently working on a big project for the US market, and are having to put in some substantial overtime. Hopefully this won’t go on for too much longer, but you never know…

I should be updating this site more often, but I seem to be just too lazy at the current time to bother writing about anything. (Note to self: stop being bloody lazy).

So, here’s to me not being so lazy…

Learning [insert language here]

I was just reading a post over on whitespace, and it got me thinking about learning any computer language.

It is not enough to read a book and do some examples from the book – you actually need to write something substantial in the language. Granted, it will probably suck, since you would have built it while learning the language. The important thing to note is that it would have forced you to find out and understand exactly how the language works, how things are done, and best practices. The next thing you create will probably be better, and so on.

I am going to use CSS as an example here. Sure, buy that book on CSS, but after reading it, actually go and create a full site using CSS. It doesn’t matter if you need to continually go back and check the book, or the net, or colleagues. At first it won’t be easy, you will be lost, not know whatโ€™s going on and generally confused, but if you stick at it, you will find you pick up an amazing amount of information, just by using the language. Before you know it, you will be using the language as if you had always used it.

This is how I learn’t all the languages I currently know, usually without a book, just examples on the net, and a will to learn.

Ajax-enabled user interfaces

There have been lots of people writing about ajax recently, and more importantly about ajax accessibility.

Keeping it simple, I want to focus on what happens when a user has javascript off, or the browser doesn’t support the XMLHttpRequest object. Now this may seem obvious, but your interface should work without javascript enabled. Maybe it won’t be as flashy, or user friendly, but it should work.

Our content management system (CMS) has a caching functionality to speed up the delivery of pages, and while it clears the cache when you change any content, there can be a time where you want to force a refresh. Below is the HTML for the clear cache link.

    <a onclick="ClearCache(); return false;" href="clearcache/">
        Clear page cache
    </a>

Notice that if the user has javascript off, none of the `onclick` code will execute, and they will navigate to the `clearcache` page, which clears the cache and informs them so, after which they can navigate back to the previous page. If javascript is on though, the functions `ClearCache` is called, which does all the ajax calls back to the server, which clears the cache, returning a status value. If the status is not an error a messagebox is displayed informing the user that the cache has been cleared, without refreshing the page.

Note that there is a `return false;` after the function call, this effectively cancels the click on the link, stopping the browser from navigating to the clearcache page. An important thing to note is that while the user experience is different in the two cases, they are both perfectly usable. It will even work in a text-only browser, such as Lynx.

One way to ensure that there is always some kind of fallback method is to first get your interface working without ajax. Then you carefully insert the relevant javascript calls.

You could also go the gmail route, and have two totally separate interfaces, one for modern browsers that support ajax, and another plain HTML interface for older browsers, however this is a lot more work, to support (usually) a small minority of users.

Behold! A design!

Woohoo! No default wordpress template to find here any more. I finally got around to creating a design for this web-log. If you find any dodgy looking areas, please let me know via the comments. I am sure I will be tweaking it, website designs are never finished!

By the way, the header is derived from a photograph of a rock face on Table Mountain, Cape Town.

A couple of (small) issues with WordPress

Having been using wordpress for a little while now, a couple of things bug me. Don’t get me wrong, it is an amazing tool, and does its job well, but, as always with any software product, there are a couple of little niggly things.

Maybe its possible to do some of the things I mention below, but I cannot see an obvious way. If there is, please let me know!

  1. Adding categories from the write post page. This is a no-brainer. Currently, to add categories, I have to save my post, and navigate a couple of pages away to be able to add a category.
  2. Intelligent URL transforming. Change `images/something.png` to something like (in my case) `/g/images/something.png`. This way if my blog moves in the future, all my image links don’t break. Admittedly, it is a small problem, so this one is a nice to have. Not sure if this is possible with the different plugins (I am using Markdown).

Thats it at the moment. Two slightly annoying things, both of which have a workaround, so I suppose I will just live with it. ๐Ÿ˜‰