Sunday, March 29, 2009

Gold Code

I'd previously written that working code is worth it's weight it gold. That is true, but it's only partially true.

Excellent code doesn't just work - proven through unit tests and structured manual testing - it is also written in an obvious way. Any old code monkey can take ownership of the code and quickly understand what it's meant to do and how it's meant to do it.

If they can't just pick it up and run with it then it's not gold standard software, It's probably tin, maybe bronze. Silver at a push. But certainly not gold.

Gold standard code uses no magic numbers, instead named constants are used. If magic number just have to be used, comments are mandatory.

Gold code is consistantly formatted throughout, commented where appropriate and has variable names that follow the 5 golden rules.

Golden code works and can easily be changed by anyone.

Wednesday, March 18, 2009

Gedanken Experiment - Removing Debt

This is the first post in a series of off-topic thought experiments inspired by the credit crunch.

Imagine a world with no debt.

I'm not talking about elimination of third world debt and Make Poverty History that Bono and his pals quite rightly support. I'm talking about the removal of debt as a concept. That is, no person or company ever owing any other any money.

But would it work?

How could it work?

The banks


Would banks be able pay interest on your deposits if they couldn't invest them?
Would banks even be allowed to take deposits off you, as one man's deposit is another man's debt - the banks will be in debt to you after taking your money!

So if banks can't take or lend any money, why would they even exist?

Bricks and Mortar


How would people buy houses if mortgages don't exist? Would people have to save until they can afford that first home? And how long would that take - 10 years? 20? It will certainly be less than the normal 25 years because no interest will be paid.

So where do they live for those 10 years? In rented accommodation, government provided accommodation, or in the family home. And, if they do rent, how does their landlord go about buying the property to then let it out again?

And where are all these savings kept until the house is bought? Without banks the only option would be to buy real objects: gold, oil, commodities that appreciate in price and can be sold on.

Shares


Company shares aren't really real are they? They're just a way of a company borrowing money off a bunch of investors. And by borrowing off a number of different investors they mitigate against the risk of one investor suddenly wanting all their money back. But there's that word again, "borrowing", so shares are out and so is the FTSE.

So what do you think? Here are just a couple of the problems with this radical idea, but could it really work?

Thursday, February 12, 2009

Gone Phising?

Clever Phising Scam?


I had a text earlier from a company claiming to be O2, it says,
Just to let you know, it's almost time to renew your contract. To hear your options please call free on 0800 902 0205

I immediately googled the number and found it on a website www.o2upgrade.co.uk. They've been quite clever with the website, linking to the main www.O2.co.uk domain and using the O2 logo whilst saying that the page is under construction. But they don't forget to mention that if you want to upgrade call the number 0800 902 0205.

Googling o2upgrade.co.uk led me to discover this page, a Digital Spy forum thread where it seems that the domain name isn't owned by O2, but in fact by a chap called Jeremy Gough. The Digital Spy forum users go on to contact O2's helpdesk who say that the site is not a fake.

Let me explain why they O2 it's not a fake.

How the industry works


There must be 30 million mobile phones in Britain now. If just half are on 12 or 18 month contracts (as opposed to pay as you go) then there could be as many as 10 million phones upgraded every year.

There are 5 major networks so, roughly speaking, they would have about 2 million phones to upgrade per year, per network. So, O2 could be upgrading as many as 10,000 users per working day.

It is simply not feasible for one company to upgrade that many phones per day without multiple warehouses and logistical-nightmare-stress-headaches. So they encourage other companies to do their distribution for them, by giving them cash-per-contact incentives.

I believe o2upgrade.co.uk is one of those companies.

So the good customer service people at O2 are saying it's not a fake because they know that o2upgrade.co.uk are convincing people to stay with O2 for another 18 months and O2 are reaping the benefit.

That said, I'm still not going to upgrade my phone with them.

Update: It seems that www.o2upgrade.co.uk now redirects to the O2 upgrade page. I don't know if that's because O2 now own the www.o2upgrade.co.uk site, or whether the owner has set up a redirector to make their page look more genuine. Interestingly, the O2 upgrade page doesn't feature the 0800 number they ask you to ring...

Sunday, February 08, 2009

Working with large data sets is hard

It seems that the most difficult problems in programming today are due to massive data sets and/or a relative lack of processing speed.

Memory is free so we've decided to store everything that we possibly can. And then we have problems analysing these massive data sets.

Google have attempted to solve the problem with their brilliant Map Reduce technique. This relies on having a number of cheap PCs on your network, and because of this, it scales well.

Anyone other than Google are a slave to the Big O.

If your algorithms aren't linear or nearly linear you're going to struggle when you want to run them over large data sets, and there's not a lot you can do about it other than throw processors at it.

Should you study Maths and Physics instead of Computer Science?

I completed my degree in Computer Science with Image and Multimedia in 2001. It seems that 2001 was quite a popular time for new computer science graduates.

However, it looks as though people are starting to move away from computer science degrees and I can only speculate that it's in favour of maths or physics instead.

Jobs requiring a good deal of maths knowledge are considered to be some of the best jobs that a human being can do.

So why do a computer science degree when you could get most coding jobs with a maths degree and have all these other options available as well?

Sunday, January 25, 2009

Web Development Supported by C++

I've just been working on an update for the Spring of Hope website. They are a charity that work with disabled children in Uganda, Africa.

I'd originally written the website in vanilla HTML and simply uploaded it, but I had to rethink my strategy after the charity's owner wanted to add a few pages to the site.

Simply adding a few new pages would have meant changing every existing page to link with the new pages - something that I didn't want to keep having to do. Instead I've written a small C++ application that loads the basic text required on each page, applies a standard header and footer to it, builds a menu, and outputs the HTML page.

A couple of hours work to make future updates simple.

Thursday, January 22, 2009

Unintentional Leadership

I was flying back from Philadelphia and just before take off I looked across to see a tall chap asking the the air hostess for a seat with more leg room. She told him there were none left.

Once the seat belt sign went out, a fella got up from his extra-legroom seat and went over to the tall chap to ask him if he wanted to swap. Of course the tall chap agreed, and the exchange happened.

I know this generous fella was a team leader as I'd seen him and his new team on the shuttle bus on the way out. They were heading out for a training session.

His team weren't sat next to him on the plane, but they were close enough to realise that their new boss would give up his precious extra-legroom seat for a stranger in need.

If he would do that for a complete stranger, what would he do for one of his colleagues, one of his team mates?

Now that's leadership, unintentional leadership.

Thursday, July 24, 2008

5 rules of variable naming.

When I was at uni some 10 years back now, I remember one of my lecturers telling me not to make variable names too long because you would get "pain in your fingers".

Well, rule #1 goes against that advice:

1. Make your variable names long and descriptive
Visual Studio has IntelliSense, Eclipse has its own code completion, and I'm sure whatever IDE you're using can finish your variable names off for you, too. Using long names prevents the ambiguity of short or cryptic names.

2. Put units in your variable names
If you are writing an engineering application you are going to be using variables with units. Embed the unit name in the variable, for example, distanceInMM.

3. If you are using Camel Case, don't capitalise commonly hyphened, or combined words.
Let me explain.

Callback is normally spelt as one word. So, pretty please, don't call your variable callBack.

4. Never, ever use the variable name temp. The only perfectly valid exception to this rule, is when you're writing a swap function.

5. int i is perfectly valid in a small loop. I've met programmers who would crucify me for saying this, but when your loop is half a dozen lines of code long or less, int i is perfectly valid as a loop counter. It's so widely used, it's almost expected.

Wednesday, July 09, 2008

Coding is dead, long live unit testing.

There are IDEs that can generate unit tests for your class once you've written the basic class stub. Or, they'll generate your class stub for you from the unit test code.

But a unit test suite should be written to cover all of the requirements in the requirements specification. It should be the contract of what is being developed.

So, if you've gone to all this effort to create a fully specified unit test suite, why should you then double your effort to write some more code to fulfil these requirements?

Couldn't something do this for you?

Like, a genetic software generation algorithm?

Thursday, June 05, 2008

Life ROI

I enjoy DIY.

I'm not one for fitting a new central heating system or building a new conservatory, but I will paint a wall or two. I do it not only because it's rewarding but because I'm hoping it'll add some value to my new house.

But is it the best Return On Investment for my time?

Would it be more cost effective for me to spend my time reading a programming or management book and negotiating a pay rise for my additional knowledge whilst, at the same time, paying a professional decorator to paint my walls?

I'm still unsure how to measure the value gained from reading a book. Or, for that matter, how to measure the pride from knowing that the house is looking better because of me.

Tuesday, June 03, 2008

Further hat tipping

Richard Dare has already written several excellent articles on game design, I eagerly await his first blog post.

Welcome to the world wide weblog Trickster!

Sunday, June 01, 2008

OSA

May I just tip my hat to the work of Andy Budd on the Operation South America website, he's come up with a great design and made some fantastic use of flash.

Monday, May 12, 2008

What a cool robot.

We've just found out that the robot we've been working on is a MacRobert award finalist.

I'd love to win it, but there's some really tough competition.

Tuesday, April 01, 2008

Brake Lights: A Usability Study

Have you ever been navigating through the front end menus of a PS2 game and gone off to get a cup of tea only to come back and think, "Which menu item did I have selected?"

No?

That's because console developers have to adhere to strict standards, know as TCRs and TRCs, that describe in precise detail how a front end menu should behave.

For example, Sony state that the selected menu option - which could be an icon or a word - must be coloured differently to the rest of the menu. But if there are only two menu items on the first menu you encounter, how do you know which colour is the selected colour and which is the unselected?

So a colour change alone isn't enough. Because Sony et al know this they also state that there must have some sort of animation of the selected item - some sort of distinguishing feature.

So what has this got to do with car brake lights?

On old cars, the brake lights sometimes share the same housing as the rear lights. The problem with this is the rear lights just look a bit brighter when the brakes are applied. If you happen to look away just before the brakes are applied, then when you look back again it's often difficult to tell that the car is slowing.

Or, to put it another way, there is no distinguishing feature to show that the brakes are applied.

So, in 1998 the EU stated that all cars must have a centre brake light. A distinguishing feature that allows other drivers to instantly see that the brakes are applied. (Incidentally, the EU took a whole 12 years to catch up with the America!)

Make your distinguishing features blatantly obvious and your users will thank you for it.

Sunday, March 30, 2008

Mobile broadband

I want a fully blown, always on, pay-per-month, unlimited usage mobile broadband.

I want a device, much like a mobile phone, that acts as a mobile broadband server and a mobile wifi router.

I want to sit in my car with this mobile device in my pocket and for my internet car-radio to serve music through it. I want to listen again to Zane Lowe on my way to work in the morning.

I want my in-car GPRS system to auto-detect the mobile internet server and to tell the world that I'm not moving very quickly, that I'm stuck in traffic. Or to divert me off the M25 when the GPRS' traffic information server tells me that there are plenty of others parked up on it.

I want to sit in the park, open my laptop and instantly be able to access the internet through this device.

And I want this for £15 a month without the worry of data limits.

Is all this too much to ask?

Wednesday, March 12, 2008

How is refactoring like throwing out the rubbish?

In these green days, you no longer just throw out your rubbish. You rinse, separate, sort and then throw.

A process, not dissimilar to refactoring.

Some code goes into your grey, household waste bin. This is the stuff that was written before the scope of the project was finalised. It has normally been written quickly, doesn't always fit the spec, and is often bug-ridden. It can't be recycled. Just bin it.

But hopefully most of your code will end up in the blue bin. This is the stuff that can be re-used - sometimes with no changes - but usually needing a bit of washing and sorting.

You can help the process by building modular code with good clean interfaces early on in development.

In this green age, filling your blue bin and recycling old code as much as possible is essential. And this can be helped by building modular code - with good, clean interfaces - early on in the development.

Monday, February 04, 2008

Has my article been read?

So you've written a website with pages of search-engine-friendly text and you know how many unique visitors you are getting from your weblogs. But how much of your perfectly crafted prose is actually being read?

You could argue that with the weblogs of a site containing many small pages linked together you would have that information. But whenever I navigate to an article that has half a dozen pages, I know it certainly frustrates me.

So if you are writing long pages (ie, with more text that can fit on the screen in one viewing) you are going to need a way of working out whether people have actually bothered to read all that you are writing.

And once again, Ajax comes to the rescue.

Using javascript it's possible to figure out the position of the scroll bar. And using Ajax it's easy to tell the server about this position.

You could even write some server-side code to distinguish between a quick browse down the page and a full-on page read.

Tuesday, January 29, 2008

Engineering Problems on Large Software Projects

Size matters.

If you are on a large software project, you are going to face a bunch of problems that you just won't see on small developments.

And by large projects I mean multi-programmer developments based on a library of modules written over a number of years.

I said, "based on a library of modules". If you don't make your code strictly modular, you've already failed. That isn't always easy, especially when it's the day before a deadline and it's far quicker to bodge in a fix.

Given that you have a bunch of modules, with different versions of them used over several products or versions of the product; maintaining a formal build process is essential. Builds should be numbered or labelled and it should be trivial to reproduce any previous build from you version control system (you do have a version control system, don't you?)

Some formal structure to record who has what build is also needed.

Code re-use generates code as structural patterns are needed to ensure your new module can communicate with the existing functionality.

And with all this extra interfacing code, finding the guts of a particular function or class becomes a real issue. Although Google intranet search tools can certainly help here.

If you've only ever hacked together 2-day projects in your bedroom, these issues will be alien to you. Anyone who's worked in a real software house should be familiar with most if not all of them.

Friday, January 25, 2008

The new SI units

"Have you heard? The smiths won the lottery last week and the house they're looking to buy has a garden the size of 2 football pitches!"

But a football pitch can vary in size from 4,050m2 to 10,800m2.

And new mp3 players are often quoted as being able to store a certain number of songs, for example the 1Gb iPod shuffle can store 240.

But is this 240 average 3½ minute radio edits?

Or 240 20-minute drum and bass epics?

Or does it even matter?

Using a commonly known "thing" means far more to the average user than an exact figure. Approximating information is a good thing.

If you're only presenting information with 1 or maybe 2 significant figures, do you really care how accurate the unit is?

Monday, January 07, 2008

Company Culture

We hear about company culture all the time, but until you've worked in a few companies it's hard to understand how two software development houses can feel so different to work at.

The Team


A team based company will normally separate groups off into their own little rooms or sections of the open plan office. There is likely to be a hierarchical structure to each team with a one or two Chiefs and then many Indians.

Games companies typically tend to have this structure as game building is very much a large team activity, especially with the modern consoles and large budgets that accompany them.

The Consultancy


Consulting companies tend to treat staff as experts in their field. The company understands that if their staff can't solve a problem, they'll find someone who can.

In this type of company you'll be given freedom to work and you'll be treated like an adult. But you may be left to just get on with it.

This type of company would tend to employ someone with experience rather than a fresh graduate and the office is likely to be fully open plan.

The Start-up


Small, agile, and with time to market a priority, start-ups can be fun, energetic and hectic. If you're lucky enough to have an office you'll be sharing it with just a handful of others, some of whom may have experience but all of whom will be passionate about what they do.

Expect to roll out core software on Monday.
Explain it to your client on Tuesday.
Fix a bug in it on Wednesday.
Deploy a fixed version late Thursday evening.
And spend Friday afternoon in the pub with the directors celebrating a great week.

Don't be surprised if you get asked to help build the company website or install a company-wide version control system as the company will be too small to have a dedicated expert in that field.