August 17, 2007
by Branden
Like most creative activities programming comes with it a certain level of inertia. It can be very difficult to start but once you're rolling it can be tough to stop (hence my nasty addiction to high caffeine drinks like Red Bull and Bawls!). Beyond this interia though there is another issue that often throttles new programmers - how to start. They desparately want to start programming up some awesome idea, but they just don't know how.
In fact I recently realized that "How do I begin?" is probably the most common question I get. In many cases the answer begins with the old standby design pattern Model-View-Controller (MVC). If nothing else MVC lets you divide up your project into managable chunks. If you're new to MVC check out Apple's explanation of MVC - I tend to think it's one of the better explantions of the concept.
Notice above that I said the answer *begins* with MVC! MVC is a shove in the right direction, but after that you need to put on your thinking cap. The exact process that you go through depends on your project - it's like riding a two wheel bicycle, someone else can teach you but ultimately you have to start pedaling on your own. Unlike a bicycle though, every programming project requires a little bit of wobbling around figuring out what to do! So if you're interested, keep on reading and watch me wobble about a bit!
One project I've been meaning to do for a long time is to make an online version of one of my favorite board games - Abalone. The rules of the game are very simple - it's one of those minutes-to-learn-but-years-to-master-types of games (in fact my first girlfriend taught me the game and I'm still not very good!). I didn't get around to writing the game for so long because I didn't know where to start - with it's hexagonal grid and multiple types of moves it just seemed too complicated!
When I finally did figure out how to begin it was through what I call problem minimization. I simply kept breaking down the problem until it was as small as possible. What's the smallest part of Abolone? A single position the board - let's call it a node. Each node can contain either a black marble, a white marble, or no marbles. Each node also has 6 neighbors. This concept ends up being a variation of a data structure that every computer science student learns in the first or second class they every learn - a linked list. But in our case it's a linked hexagonal grid, not just a list!
In the next post in the series I'll whip out some ActionScript 3 for an Abalone node and show how you use this node class to enforce the rules of the game. Stay tuned!





