Unit tests are good

November 10, 2007

Some developers can write code from start to finish and and end up with a complete and useful solution. I used to think I was one of those developers. Now I don’t think so much of myself. I tend to write some code that’s good enough for the moment, and build on top of it like a stack of cards which at some point starts to collapse under its own weight. In the past, this is the point at which I lose interest in the project and usually banish it to the code archive.

Lately I’ve had some spare time to spend on the game project I have worked on in the past year. After spending some time away from the code, I felt the need to refactor the code. The game-specific code was tied in with the engine code enough that it became somewhat of an overwhelming jumble. So I decided to attempt a clean break from the engine and the game code.

While I am doing this, I am spending the time to do unit testing. While I wrote some tests for the base display, input, and sound objects on the first pass, I didn’t attempt to write a thorough unit test, which stressed all of the features of a particular module. Is this a waste of time? I’m not sure, but it’s a different approach than I’ve taken in the past, and in the past, my code has tended to wither away and disappear after becoming stale. I hope to keep this code around and launch a few more projects based on this engine so for ow I’ll continue to work on it.

In the past, due to self-diagnosed ADD, I’ve taken on lots of projects at one time and worked hard on each of them for a short while. Inevitably I find myself overwhelmed at some point and losing interest in one or more of the projects and they fall into oblivion. How I’d rather things go is that projects fall away and my time frees up for new ones as old ones get COMPLETED. Here I’ll try to nail down what I am doing wrong.

1) Productivity in bursts rather than steady progress. I can spend a few weeks being really motivated on a new project and put in crazy amounts of hours working. But I always discover some time later that it’s been a week or 2 since I’ve done even one thing to bring the project closer to completion. To remedy this, I’ll try to keep a list of projects around which I can refer to during any free time which I have. This way my excitement for a new project won’t allow me to forget existing projects I have going on.

2) Trying to do everything myself. I have a bad habit of doing this. I’m sort of a perfectionist. And I don’t trust other people. This shows up ineverything I do, I fix my own cars and motorcycles, write my own software. This isn’t good, since modern society allows us to accomplish great things based on division of labor. I find myself constantly fighting this rather than embracing it. I’ll spend a whole weekend working on a project I could pay someone else to do. And that someone else can do it in much less time, so it actually costs less to have someone else do it. I’m not saving anything, especially not my time which is the only thing I can’t ever have any more of.

A better way to view the process is like this. If I CAN do everything myself, then I have a good mental view of the project beginning to end, and can coordinate all the pieces better than someone with less experience who CAN’T do everything. So I am more useful when I allow others to take care of specific aspects of a task while I oversee, rather than get caught up doing all of the tasks myself.

I like python

March 10, 2007

I just got done reading

    Chance

by Amir D. Aczel, which was a fun, quick book about probability and how it applies to various scenarios in our lives, including gambling. This book was by no means a rigorous study, but it had some good explanations on determining probabilities for simple situations. What I got out of it was a little motivation to revisit my gambling past and, along the way, mess with python.

One of the blackjack games I used to play had a side bet called a “Royal Match”, which was basically a bet that 2 cards of the same suit would be dealt to you. The probabilities for this side bet when playig with a full deck of cards is fairly straight forward. But I wanted to run some simulations to see what the probabilities looked like at various points dealing from a randomly shuffled deck. So I started writing a python script to simulate any number of decks being dealt and to determine probabilities. Within a few hours I had all the data I wanted generated by this script. I used a few online references for some syntax help, but it was relatively painless to whip out the script. So I think I’ll start using python more often for prototyping algorithms and such.

As far as the results of the Royal Match bet, I’m working to devise a count that can take advantage of positive situations. As soon as I get to a point I’m happy with I’ll add it to my projects page.

I’m juggling so many projects that I feel like I’m a clown at the circus. Having your hands in a couple of potential money making software projects is a good thing, but also I’m trying to make sure I don’t spread myself too thin and get stuck with 10 unfinished apps.

Since I’ve struck out on my own as a software developer, I’ve been learning many good lessons on software project management. I’m realizing how difficult it was for those who I have worked with in the past. And now with myself being the sole developer AND project manager, I sometimes feel overwhelmed. The most difficult part I’ve found is stepping back from the code enough to work on solidifying design and making time estimates. I, like most coders, I’m sure, have a tendency to want to jump in to writing code and not look away from the screen until it’s finished. It’s difficult to recognize when to take a break and gather new requirements, define pieces that were left for later in the project, and to estimate how far along the project really is. Personally, I have difficulty with cramming at the end of projects because I always feel they are closer to completion than they actually are. I’m working on that one.

Now about those projects…

The prediction market software isn’t much more than some database tables at the moment. Design is nearly complete, but I’ve been busy with the other projects for now. I have been thinking about this one, though. My direction will be to crate a PHP/MySQL based prediction market solution as a plugin to wordpress and/or drupal. Then I supply a free download of a user-limited version which will allow corporations interested in using the software to install and test it out before they commit. Also, having an online demo is a good way to draw interest. Since this project is moving the slowest, I may solicit help in its development. This is also, in my eyes, the best potential moneymaking project I have right now, so I should bump its priority up.

The second project is a 2D game running on Windows, in partnership with a designer/artist. I’ve been hard at work on the engine/framework and am getting into the game logic code right now. This project was great for bringing back my game coding, Windows API, and DirectX skills. It’d been years since I’d touched games and I had forgotten how fun they are to develop. I’m putting in as much time as I can with this project and it’s making alot of progress. Unfortunately, this is where I need to step back and make sure design precedes code. While I’m waiting for design and artwork from the other guy on the project, It could be possible to whip up a small design for a card game or puzzle game, something simple to show off the work I’ve done for the engine/framework which wouldn’t take much time to code. I’m anxious to have something to show for the work I’ve done here.

The final project is my most time consuming. It’s a contract job for which I’ve signed an NDA, so I can’t say much about it other than it has to do with gaming. Not as fun as designing my own game, but not as terrible as being a database developer. I’m hoping this project will wrap up within the next week and I can focus on other things. Unfortunately, when it comes to paying the bills, I have to put projects like this one first.

Which reminds me, anyone need a coder?

Back to the Future

January 15, 2007

While my first contract job here in the big city is coming to a close, I’m starting to think back to my own project I had been working on. I became interested in prediction markets last fall so I read up and studied as much as I could about them. The idea of predicting the future by using a market with contracts based on some future event is really cool. I joined up a few of the big sites and played around a bit. Then I had a thought. Why is there not more interest in these markets? One conclusion I came to was that the mechanics of a market are not something the average person is familiar or comfortable with. Also, my own interest in the markets waned because the lack of participation caused lulls in the action.

So I started working on how I could improve the prediction market to draw more interest. The conclusion I came to was a model where the contracts could not only be presented by a market mechanism, but also by a simpler betting model, the parimutuel betting pool. This is a mechanism used in horse races which is familiar to those who bet on sports. Presenting the prediction in a parimutuel form would cater to different bettors who do not want to use a market interface. In a nutshell, the bettor (investor) would place a bet amount on a particular choice. Once a winner is chosen, the money pool is distributed to the winning bettors proportional to their bet amounts.

Then I realized this could be taken one step further. The contracts could also be used with a poll, or lottery, mechanism. In this form, each participant would ante up a predetermined amount and select their guess. The pot would then be distributed in some fashion amongst the winning guesses, usually by giving the entire amount to a random participant. This big win amount should stir up interest by those who don’t wish to use the more complex interface outlined above.

Finally, these 3 methods are linked together by calculating the probability of a particular outcome based on participation. The probability of a market contract would be inherent in the price of that contract. The probability of a parimutuel choice would be the amount of money bet on that choice divided by total money bet on all choices. The probability of the poll, or lottery, would be the number of guesses on a particular choice divided by the total number of guesses. With these 3 probabilities available, it is easy to aggregate the 3 methods into one information pool which will track the current probability of all the possible outcomes of an event. There are some hurdles, such as the need to allow the poll/lottery model to incorporate new information about the event. This can be done by allowing a participant to withdraw their choice and guess a different one.

I feel that this presentation model could allow for much greater interest and participation, which would provide greater accuracy in probability of events, which in turn is more valuable to those who are relying on such statistics. I hope to take this idea to completion and create the software necessary to provide this interface.

New York, New York

January 9, 2007

“If I can make it there, I’ll make it anywehere…”

So goes the song, and now it applies to me. Almost 4 months since the last entry and much to talk about.

I’ve relocated to New York in hopes of scoring a high class coding job and came to the harsh reality of my situation. I spent the prior year hacking up java ui code, hadn’t really coded anything worth a damn in 3 years, and now live in the second most expensive city in the world where the competition is stiff. My resume looked like a 3rd grader wrote it, I completed my BS in physics just months ago, making me look inexperienced (or stupid, considering i’m 29), and all remnants of code I had written myself were long gone.

I’ve progressed and changed alot in these short 4 months. No full-time job but I’m doing freelance work and working on my own projects in my spare time. It’s rather nice and I might just prefer it to a cubicle in a high-rise.

Ruby Friday

September 8, 2006

What is this Ruby on Rails crap that everyone is talking about? I figured it was time to find out for myself. Ruby is a scripting language which at this point in my investigation doesn’t stand out as much different from many scripting languages I’ve come across. But it seems to be the hot ticket for server side scripting when used with a particular toolkit called Rails. Hence the term “Ruby on Rails”. Watching a quick screencast from the Rails site, I was pretty impressed with the web stuff built in to Rails. The one I saw showed a quick creation of a weblog site with form entries and data retrieval and display all built in to the Rails toolkit. Here’s where I got started:

Ruby: http://www.ruby-lang.org/
Rails: http://www.rubyonrails.org/

Peer-to-peer

August 29, 2006

Peer-to-peer apps are cool and useful. I think there is alot of potential there. Sure you can read this and think “Where the hell has this guy been the last 3 years?”, but I think alot of the potential has yet to be realized.

That’s where the coders come in.

So what can be added to p2p architecture? What visions have not been realized? That’s the question I’m pondering today as I gather information in the p2p realm. I’ve found that Warner Bros will be delivering content via BitTorrent in the future. This is a good first step for the real content providers. Now, with p2p being the delivery mechanism, how about a joining of the media, delivery mechanism, and content management? Isn’t this why iTunes has become so popular? This is where “The Lonely Coder” comes in. While others can expound on ideas and not get anywhere, the “Lonely Coder” can do something about it. He can visualize, build, create.

I found a good starting point for information on p2p architecture at the wikipedia article on BitTorrent.
http://en.wikipedia.org/wiki/BitTorrent

Where to start?

August 28, 2006

As I try to pull myself away from my other big project, my motorcycle, I’m pondering what project I should take up in my downtime. A little history…

I originally started coding at 15 or so, self-taught as many were back in the days before the internet and rampant nerd-dom. What I was drawn to was graphics, 3D stuff, games, all very visually stimulating. I dabbled in some other things but this was my love, the thing that kept me at the computer until dawn.
Since taking up software development as a career, I’ve swayed from this initial interest and followed the jobs available to me. I’ve written network code, UI code, web code, whatever.
So here I am, a crossroads in my development career. I’ve got the typical hacker creds: C/C++, some asm, some graphics API’s. I don’t have any experience in the newer web app type languages like C#, .NET, javascript is an afterthought as far as I’m concerned. Now do I jump in and learn these new technologies to keep myself employable? Or should I build on my past experience. May be time to dust off the 3D books and throw a few flashy demos together.

As I sort these things out for myself, I’ll try to keep a good blog going and hopefully provide some entertainment to others as I do it.

Introduction

August 26, 2006

Today I find myself 2 weeks out of a contract job which has ended. I’m looking at a few more weeks of probable unemployment so I decided I might as well spill my guts here. My hope is that adding some structure to my life by writing each day will prevent the typical unemployment depression I’m sure all of us have experienced at one point or another.

While I hope to use this blog as an outlet for anything I’d like, the title ‘The Lonely Coder’ may provide a loose theme. I’ll discuss later my thoughts on being a lonely coder in this world.