Truly Awful Code

So, on the back of my previous post about people designing applications for mobile devices having never even used one, I am now working for an employer who would appear to have never read any guides on how to code in Objective C – or any kind of language for that matter.

We’ll start with this simple bit of code that is not only written badly, it also contains 2 errors! ¬†Assuming this person had any schooling, I think they missed the classes on “else if”, “switch statements”, “enumeration” and “top down programming”.

[sourcecode lang=”c”]
if (yourScore < 12) { gameState = 1; } if (yourScore > 12) {
gameState = 2;
}
if (yourScore > 24) {
gameState = 3;
}
if (yourScore > 37) {
gameState = 4;
}
if (yourScore > 49) {
gameState = 5;
}
if (yourScore > 62) {
gameState = 6;
}
if (yourScore > 74) {
gameState = 7;
}
if (yourScore > 87) {
gameState = 8;
}
if (yourScore == 100) {
gameState = 10;
}
[/sourcecode]

The two errors are:

  • How does one achieve game state 9
  • And what if a persons score == 12

Continue reading Truly Awful Code

Triumph Configurator iPhone App

[singlepic id=91 w=64 h=64 float=left] This is my take on the the Triumph bike configurator for the iPhone.

It is currently Beta as there are still a few bugs and features that need to be removed/added.

The following are screen shots from the App.  There is the main screen where you choose the bike and the language in which you want to view prices and information, followed by sample customisation screen shots :

[singlepic id=87 w=320 h=240 float=] Continue reading Triumph Configurator iPhone App