Should a failed function return a value or throw an exception?

March 11, 2010 – 5:58 pm Tags:

You have created a nice, well written function, but you realize you forgot something: The failure case.

What should a function do when it fails? There are two schools for this - the “throw an exception” school and the “return an error value” school.

But which of these is the correct approach?

Read the rest of this entry »

Benefits of Developing With Microsoft AND Open Source

February 26, 2010 – 8:06 pm Tags: ,

The Internet seems to be the latest battleground for the computer age-old struggle between Microsoft and open source solutions. For some reason, many web developers like to engage in holy wars over various web site hosting solutions and development platforms, fiercely defending their beloved vendor’s suite of products. They battle over their particular setup so much they block out any new ideas they might gain had they kept their minds open to how things are done on the other side of the castle walls.

Read the rest of this entry »

Should PC’s be easy to use for everyone?

February 24, 2010 – 7:02 pm

Should PC’s be easy to use for everyone, or should you actually need some kind of understanding of how they work?

I recently saw an article about a new computer aimed at “computer illiterate” users, the Alex PC. Elsewhere on the ‘net, people were arguing about whether or not trying to make it easy for “non-geeks” to use computers and internet was a good idea or not, which provoked some thoughts which I thought I’d share.

Read the rest of this entry »

Can you make JavaScript’s String mutable?

February 12, 2010 – 8:01 pm Tags:

Here’s a question I was pondering a couple of days ago: Can you make JavaScript’s String object mutable, as in modifiable without having to re-assign the string.

Why would this be useful? Sometimes you might share a string between objects, and you’d want changing it in one place get reflected in elsewhere. If you had a single string object, which was referenced from multiple places, this would be simple.

But it turns out, it isn’t…

Read the rest of this entry »

6 programming project mistakes you should avoid

January 28, 2010 – 6:45 pm Tags:

During my adventures in programming, I’ve been involved in many projects. Luckily, despite having made some mistakes, they’ve gone quite well. Here are a few of them, with tips on how to avoid making them yourself.

Read the rest of this entry »

How much would you pay for good headphones?

January 14, 2010 – 9:09 pm

Time for some consumer advice today.

I’m sure many of us have often thought about getting headphones - and I’m sure many of us already have a pair - but how much is a reasonable amount to spend? And what will a higher-grade (read: more expensive) pair do that’s worth the money?

I recently decided to invest on some new headphones. The AKG K 701’s to be precise. They aren’t exactly very cheap and you’d probably want a headphone amplifier to go with them, one which I incidentally also bought. I’ve also had some more reasonably priced headphones in the past: Sennheiser HD-555’s and going down in the price range, some Koss and Philips ones.

My opinion is that great headphones can make listening to music much more enjoyable. However, should you go all out and buy expensive ones like the AKG, or is it smarter to purchase something else?

Read the rest of this entry »

Rendering graphics in JavaScript games

January 7, 2010 – 2:49 pm Tags: ,

As I’ve been rewriting TankWar, I’ve been thinking of various approaches to displaying the game’s graphics. At the moment, I can count three feasible approaches for rendering game graphics:

  • DHTML - In other words, using divs with images and moving them around
  • Canvas
  • A hybrid: Canvas with DHTML

I’ve considered each of these, and they all have some pros and cons which we’ll look at next.

Read the rest of this entry »

Best of 2009

December 29, 2009 – 8:34 pm

In the tradition of end of the year posts, here’s some “best of” statistics from this blog for the year 2009.

Next week we will return to our regular programming.

Read the rest of this entry »

Vim / Opera tip: Open highlighted text in Vim

December 22, 2009 – 6:50 pm Tags: ,

Here’s a quick tip for Opera and Vim users: How to add a menu item which allows you to quickly open highlighted text on a web page in Vim.

This trick can be applied with any other application too, like <insert your favorite editor>

Read the rest of this entry »

Rewriting TankWar: Assessing the damage

December 16, 2009 – 7:22 pm Tags: , ,

I have decided to rewrite TankWar, and I’ll be writing a bunch of blog posts about the process. If you ever wanted to know how to write a scorched earth/worms-like game using just JavaScript, now is your chance to learn ;)

This is the first one: Assessing the damage. In other words, take a look at the old code and see what can be salvaged. I’ll also list some issues with the current implementation, and how I plan on solving them in the new version.

Read the rest of this entry »