Sunday, March 25, 2012

Test Driven Development == Granting a Wish


In test driven development, if you're doing it right, then you're likely to be writing code that is wrong.

I don't mean that in a bad way, quite the contrary, but it's one of the oddities of test driven development that makes some people run away, fast.

For example, when your'e starting to write tests for some system, the general solution for the first version of the code is to write a function that just returns the value the assert was expecting:

test: assert( Foo( 5,3 ) == 1 )
code: Foo() { return 1 }

.. most people seeing this as a first step laugh, or just comment about how dumb it is. But this element of _the simplest thing that will work_ is often overlooked. It's actually one of the most important things to get hammered into your head as early as possible.

The tests are being tested too

TDD makes you evaluate your tests. This is really important because most software design methods take a problem and design a solution for it. TDD takes an unfinished solution (empty project) and refines it until it works for all tests you can think of.

Which brings me to my point. How many of you have granted a wish?

In Dungeons and Dragons, the wish spell is one of the most annoying and powerful spells in the whole game. It can do anything. Literally, but how the DM grants a wish is up to him. The player has to be very careful about how they ask for what they want, otherwise a completely innocuous request can go awry and could commit genocide.

and so he said, I wish that all traces of the disease was eradicated from the elves. at which point I told them that all the elves caught fire and died.

See, tests in TDD are just like wish spells. You make a test and then you go and do the easiest thing possible. Sometimes it's easier to just burn all the elves / return 1. Sometimes, the test requires better coding. It's the act of refining in TDD that gives it its strength. You can get inspiration for what test to write next from what you did to make it pass last time, and every time you think of something to make the test pass, you can think of a new test that breaks it.

That's how we get to a final working solution. We keep on adding more wishes adding more criteria so eventually you find a way to cure the disease while keeping your elves raw.

Wednesday, March 21, 2012

The death of the high-street game store


I was told on the train back to Aberystywth one time, by a student of economics, that during this time of recession, at least I wouldn't be hit as hard. He said that, though luxury goods sales dwindle, entertainment related products and services historically maintain a healthy trade.

But seeing this happening to Game, I wonder how true this can be.

It's the tipping point for my argument. No-one in games is getting anything like the money we would have seen before the recession, and yet I'm told to my face that at least my profession won't be affected.

So, what's going on?

I suspect that the economics student is right. I suspect that the market for entertainment is just as strong as it's always been, but much more worrying is that the market I am working in is not all of entertainment, but just one corner of it. And, due to the recession, anyone talking about a dwindling market, could well be blaming the slow death of profits on something that doesn't naturally or actually have any impact.

Maybe we're experiencing a recession at the same time as the games industry is experiencing a change of course. The way to make money is changing, and because the recession looms, it's not obvious that we're dying by standing still.

The highstreet retailer model is being crushed from two sides. Boxed games are a dying breed, but so is buying games at a shop.

They were definitely going to die.

I feel that a lot of games developers see the reason they're not being paid well in the shadows of other narratives. Some see Steam or Origin as a way to save them from pirates, which they assume to be the ones costing them their wages. Others see that it's the second hand game market. Neither seems ready to admit that people are actually buying more games than ever before. The only real problem seems to be people wanting to make AAA games when the majority doesn't value those games any higher than some grumpy avians.

Entertainment makes money, otherwise Apple wouldn't be the largest company in the world right now. The games industry needs to recognise that being stubborn and doing it the old way, making block-buster hits, though it brings in millions, might not be enough any more. When you bet millions to make millions, while others are tossing peanuts and making a good percentage of what you're expecting back... well, you've got to ask yourself: are you doing it wrong?