Flex is a great Game Development Language

September 6, 2008

There’s a lot of misinformation about Flex in the gaming community. Most people think you can only use Flex for boring business stuff – graphs and so on, and you have to use Flash/CS3 for games. Or they are misled by the fact most introductions to Flex want to talk about only MXML.

They don’t realise that Flex is simply a proper programming environment to create Flash applications using AS3.0.  On the other hand CS3 is primarily designed for creating animations, and as a side thought allows you to add code.

You can’t create decent artwork in Flex, just like you can’t in C++ – but you can write games in much more organised manner, like you would in C++. I’ve been working on a Flex game for about a year now (in a small team) and Flex(Builder) has proved itself as a perfectly good development environment for AS3… proper debugger, resource editor, etc. We use CS3 for artwork and the great thing is Flex has pretty seamless interop with Flash SWFs.

The bottom line is, Flex is designed for programmers, and Flash is for artists. If you’re used to modern IDEs and good coding tools, and you want to make a browser game, then FlexBuilder is the way to go.


Just Spend the Damn Money!

May 1, 2008

Of late, I’ve been looking to expand my library of technical books (despite having worked in quite a wide cross-spectrum of the software industry there’s just so many technologies out there). For whatever reason, I get on much better with a physical book in front of me than scouring the web for tutorials.

You know what I found? It’s really hard to tell which books are any good. If you don’t have someone to recommend a book, you’re pretty much left with reading Amazon reviews. Now that might seem to be a pretty good second best – if you can find a book on the right topic with 50 reviews averaging 4-5 stars, it’s got to be good, right? Well no, not really. You’ve no idea who those reviewers are… are they 20+ year grizzled veterans wishing they could dump Ruby and do everything in C… or perhaps know-it-all college students who give a book on EJB 1 star because it doesn’t tell them how to use packages. Really, the usefulness of any book is going to be very dependent on your current level of experience and how your mind works.

So I would spend hours reading reviews of the top 10 books, trying to evaluate the reviewers competence from a few lines of text. And then as like as not, the book would still be totally useless, and I’d wasted $50-60 (in the UK, books are about twice as expensive as the US).

But then I realised that compared to the $60 I wasted on a book, the time I spent poring over Amazon reviews and book contents was far, far more expensive. Speaking approximately, I charge about the cost of one book for each hour I work. I was probably spending at least 2 hours on average, choosing one book on some subject. So with the cost of the book thrown in, that’s at least 3 hours worth “spent” on a book.

Here’s an alternative approach. Imagine I scoot across to Amazon and do a search, very quickly skim the top few books and semi-randomly pick 3 of them. Time spent: practically 0. For the same cost, I still have my book. In fact since I have 3 books, I reduce the risk of not getting anything useful. And of course, I actually get some work done… which looks good when you have deadlines to meet and clients to impress.

It’s an approach I think is applicable to other areas too. For instance, do I redecorate my bathroom myself, or pay someone $100s to do it? Well, a professional can probably do things (at least) twice as fast as I can, and to a better standard (it’s not really my forte). So as long as he charges less than twice my hourly rate, it makes sense to hire him, as long as I spend the hours I would be decorating doing paid work. Another example; UK supermarkets will let you order online and have your weekly shopping delivered for about $10. If you’re used to trying to be economical, this might sound crazy. But $10 is about 10 minutes worth of me being paid, whereas shopping online probably saves about an hour of my time… for spending that $10 I can be $50 up on the deal – plus as an added advantage I don’t walk past the snack aisle and come home with a bag full of doughnuts and hot chicken!

So to summarise… if you work for a decent rate, the time you spend saving money may be far more expensive than the money you save.


Hospital Emergency

April 1, 2008

Problem
A team of N doctors are working in a hospital emergency room after an earthquake. The doctors are all on the same shift, which is SHIFT hours long. There are a number of wounded patients. Each patient has a probability (as a percentage) of survival if not treated, a time (in hours) required to treat them, and a probability (as a percentage) of survival if treated. This data is encoded in an array strings PATIENTS, each element describing one patient in the form:
“<TREATED> <UNTREATED> <TREATMENT_TIME>”
e.g “56 78 5″ means the patient has a 56% change of survival if untreated, or a 78% chance of survival after treatment, which takes 5 hours

You should return the maximum expected number of surviving patients.

double expectedSurvivors(int n,int shift,string []patients)

Notes:
 – each patient can only be treated by one doctor

Constraints:
 – n is between 1 and 10 inclusive
– shift is between 1 and 100 inclusive
– patients has between 1 and 50 elements inclusive
– each element of patients has only whitespace and numerical digits
– for each element of patients, TREATED and UNTREATED are between 0 and 100, inclusive
– for each element of patients, TREATMENT_TIME is between 1 and shift, inclusive

You can post code… but I can’t actually test it.


All Set Up

January 8, 2008

Following from my last post, I’m now the sole director of my own personal company. I have a business bank account, an accountant, and the tools I need to keep my company books in order. I’ve even registered the .co.uk and .com domains for my company name, so nobody else can!

I estimate that I’ve spent about 8 hours on getting everything set up,  at the outside. And I didn’t have to leave the house once. The accountancy firm is set up to let me do as much as possible online… I had to post proof of identify was about the only exception. And Abbey were equally easy. I’d had visions of going into a branch somewhere for multiple meetings but the truth is it couldn’t have been much easier.

Now… back to work…


So, how do I start my own company?

December 31, 2007

I recently left the world of 9-5 software development, and now I work from home as a freelancer. While it’s not required, many people doing this in the UK set up their own limited company.

I’m going to describe the process of getting yourself set up in this way. I think you’ll be surprised how little work and money you actually need to become director of your very own company.

Firstly, you actually need to create the company. Companies in the UK are registered with http://www.companieshouse.gov.uk/ and you can fill in forms and pay a small fee to do it directly. But many companies will do all this for you – you simply select a company name and give some details and they do the rest. You can do it all online, even, and in most cases your company will exist by the end of the day! Places like here allow you do do it for just £75 (+VAT).

To start a company you must have at least one director (you) and you must also have a company secretary. This person has very few responsibilities and does not have to receive shares in the company or a salary… many people use their wife/husband/parent.

You will also want a business bank account. All the banks you’d go to for a personal account also provide business accounts, but there is a tendency for them to charge for just about every action you’d want to take. I have been recommended The Abbey by many people, as not only is it free, but you can operate your account online. You can also apply for an account without having to go and visit them – you just post them an application form and some photocopied proof of identity/address.

Finally, you’ll probably want to hire an accountant. It’s not at all essential but unless you want to delve into tax law, and are confident you can do it all correctly, an accountant is something you need. As well as making sure you don’t accidentally commit fraud, an accountant can figure out what you can claim as expenses against tax, and generally make sure you pay as little tax as legally allowed.

Personally, I’d rather be making money than poring over tax documentation. I signed up with Quay Accounting. For £66 (+VAT) a month, they do everything. I will give them my income and expenses each month and they will not only do the tax for my company, but also my personal tax returns, as well as sorting out the salary I am paid by my company. They also operate a company creation service (it cost me £100 to get my company set up) and can provide a bank account, although I preferred the Abbey account over theirs. Basically, using a full package like this means I can get on with doing some actual work.


On the night before Christmas…

December 27, 2007
…All through my house
Nothing was heard
Except the click of a mouse.
While others wrapped presents,
Or drank hot, mulled wine,
This coder was coding,
On a fierce deadline.

Freelancing isn’t all about lounging at home eating biscuits and throwing in the odd hour of work every now and then. The flexibility I get is great – after a mid-week deadline I can decide to blow off an afternoon to go out for coffee – but it does have a flip-side. If you take on work it’s up to you to get it done, and that means if you take on a short-term contract on 22nd December you are going to work long hours on Christmas Eve. I did an 18-hour day on Christmas Eve, crawling into bed in the early hours of the 25th.

But I did choose to do it. Of course I did – I didn’t have to take the work. I signed up for two software design components on TopCoder knowing I had a good shot at $4000 for two days’ work. And frankly, that kind of opportunity is hard to turn down when you’re just getting set up as a professional freelancer – if I were working in a 9-5 job that’s nearly a whole month’s salary!


2 Weeks Later

December 18, 2007

I’ve now been working as a freelance software developer for a couple of weeks. So far, it’s going OK. I have plenty of work – in fact there’s considerably more work than I could manage when you take TopCoder’s design and development projects into account (if you sign up please enter d000hg as referrer, and feel free to message me and say “hi”).

I’ve been looking this whole time into the legal ramifications of working as a full-time freelancer in the UK. I essentially have 2 options:

  1. I can work as a “sole trader” which basically means I just do work, get paid, pay tax & National Insurance (I think that’s equivalent to social security in the US?) – it’s just like a normal job except I have to work out my tax returns each year.
  2. I can set up my own “limited liability” company, and trade through that. That means creating a company, taking a salary, figuring out tax for both the company and myself as an individual, having a business bank account,…

I’ve picked 2). I’ve picked a name and am in the midst of getting my company incorporated. It might seem a lot more complicated, and it is. Although, actually becoming the owner of a bona fide  company is very easy, and cheap too. There are at least 3 reasons why it’s sensible for a freelancer:

  1. As a sole trader, if you end up owing a lot of money then all your belongings and personal wealth are up for grabs. With a company, only the company funds can be taken if things go wrong – your house, car & personal savings are safe.
  2. There are potentially quite large tax savings to be made. You can take a small salary and then take director’s dividends also, which basically means you take the same amount of money but pay less.
  3. It looks a whole lot more professional if you own a company.

It’s too complicated to explain now how the tax savings are possible, and it’s only applicable to the UK, but if anyone’s interested post a comment and I’ll post some links or more information.

As I said, it’s a lot more complicated this way. In fact the vast majority of people hire an accountant and that’s what I plan to do. They can do pretty much everything, leaving you simply reporting your income and expenses and free to get on making money. An accountant shouldn’t cost more than the equivalent of 2-4 hours of what you charge per month, and I could easily spend that much time doing it badly!


Follow

Get every new post delivered to your Inbox.