Wednesday, 30 January 2008

When games programming experience becomes valuable for solving other problems.


As part of the large multimillion pound project I'm working on at work, there are lots of little tools that I've had to build to aid content authors and the technical team in the development process.

One of those tools is an automatic menu generator. We have a slight problem where, as part of the resources we're building, there are going to be about forty HTML pages with content that we don't know about and a structure that hasn't been decided yet and they need to be ready (with everything else for the next delivery) in only a couple of weeks. To top it off, the design hasn't been implemented yet either.



Developing a tool to help us to cope with a situation like this is obviously not that easy, but having some application that you can throw a template at (for the design), an XML file (for the navigation) and have it spit out the resulting transformed HTML is tremendously useful. It allows us to move quickly and meet the deadline even if the content authors are extremely late at bringing all the assets to the table. So that's what I've been working on for the past few days and brings us up to scratch with where I'm at.

I have the tool working and generating the navigation menu, which needs to show the detail for the level you are at within the structure, as well as menu options for the levels above. I use recursion for parsing the navigation XML and have it spit out the final HTML based on this; but it turns out this wasn't enough.

As each navigation branch in the structure tree could potentially contain the current page that the user is on, it suddenly occured to me that this was in essence, a pathing problem. Only the path through the resource that the user has taken to get to any particular page should be "open" on the menu. Other paths should remain closed, as only the sections that a user has gone through to get to the page they are on should be shown. I realised pretty quickly that I could bring my A Star programming experience to this problem in order to solve it. I was right. A Star is a famous algorythm used for finding a way around a map by opening and closing nodes. It normally involves a heuristic to optimise the pathing but I didn't need it for this; the navigation is not in 2D space, so that simlpified matters somewhat.

Ten minutes later, I had implemented a slight variant of A Star and fixed my menu transformation so that it produced the correct data. Bringing my games programming experience to bear on this specific problem was a huge benefit. I wonder if there are other problems I could use A Star to solve that are not game related?

Wednesday, 23 January 2008

The future is SSD.

Last month, I ordered a new Macbook laptop and an MTron 32gb Solid State Disk drive to go with it. Thirdy two gigabytes is fairly small, but I planned to expose other hard drives I have through my wireless network for heavy duty data storage, so 32gb would be enough for a boot drive.

Solid state disks have a number of advantages over their regular brethren. For one thing, there are no moving parts, meaning they use less power and generate much less friction - therefore less heat. Also, having no moving parts, they are more robust against knocks and falls. All these characteristics make them ideal for mobile computing devices.

SSD's have traditionally had a couple of weakpoints. Because they are essentially a big block of flash NAND memory, they can be much more expensive (per GB) than a regular hard drive. Also, flash memory is typically slow, especially at writing data. Not ideal to run an OS from, then.



Well, that was until the MTron drives came out. Take a look at this article from Anandtech: MTRON MSP 7000 SSD - Raptors Beware http://www.anandtech.com/storage/showdoc.aspx?i=3167 in which the MTron SSD absolutely destroys the Western Digital Raptor (previously, the fastest desktop hard drive, which I have in my G5 Powermac). 0.1 ms access time!!!! Reading that article really made my mind up (just take a look at the benchmark results). So I paid a small fortune, waited a while and the hard drive arrived.

I mirrored my data across from the standard Macbook drive and booted up from the MTron. It is very quick. Not just at booting, or shutting down (which is now instant) but at every day usability tasks. So quick, a friend of mine stated they have never known a computer be as quick as this!

My boot times went down from over around about a minute and 20 to 20 seconds. Everything loads fast. The system responds to everything you doextremely quickly. Money well spent, then.

So the writings on the wall for standard hard drive technology. A few years from now, performance like this will be available to everyone and not at a premium. Rock and roll!

Monday, 21 January 2008

HD Downloads... so where's the High Definition?

A few days ago I decided to try out Microsoft's High Definition movie rental service out on the Xbox 360. It's a relatively new service (for us in the UK anyway) and there are only 25 movies up there to choose from, which I'm guessing is a reflection of this whole thing being a bit of an experiment.
Some of those movies are offered in standard definition only (like the classic Clash of the Titans film) while some are in both HD and SD. The pricing for HD is a little steep but I figured, what the hell, I'll try it out anyway, as I quite like the idea of renting by looking through a list and downloading.

There are some issues with this model for HD content. First of all, the download size is quite large. I picked the Zodiac film (about the Zodiac killings, based on a true story) as my test film. It's not a special effects heavy film, but as I own a number of HD DVD's from when I picked up the attachment for the 360, I've learned this doesn't matter too much. Films like Serenity looks simply awesome in HD but other HD DVD's I have like a View From Space (an hour of footage filmed by astronauts heading to the international space station) are also very, very good. Plus I had heard from a couple of friends that it is a good film. It weighed in at about 6.9gb, a fairly large download, but fairly small for HD content. HD DVD and Blu Ray hold around 20 gb (or more).


Anyway, I watched the film and enjoyed it's twists and turns, but overall, thought I had picked totally the wrong film to test the service out with. That is, until I read this: Don’t believe the low bit-rate ‘HD’ lie. It turns out that the film didn't really look HD because it isn't at all. It's compressed more highly than a regular DVD!

DO NOT USE THIS OR SIMILAR SERVICES.








Wednesday, 16 January 2008

Should Singletons be avoided?

First of all, happy new year all. I've been busy and not had much time to blog recently and not seen too much on the web to really get my teeth into. Until I found this...



According to an article in the Software Development Times many developers are thinking that Singletons are bad and should be avoided. I was wondering, why, exactly? In some ways it may be because using them as houses to store global varaibles (a use I often put them to myself) may be considered bad in the same way that globals are bad. The author comments on Singletons being bad for unit testing, but I tend to find the opposite is true myself. With global variables, you have to have access to whatever code sets up their defaults or any code that uses them will fall flat on itself when used in isolation of the main project. With a Singleton, those values are set up to their default values when the instance is requested for the first time, which it will be with a class that is being tested outside of the main project. So I'm left wondering, why would there be a backlash against Singletons as a design pattern? Is it that developers are struggling with OOP concepts (especially design patterns) and frequently misuse them?