Making Wrong Code Look Wrong

Here’s a very good article by Joel Spolsky that you should read. It talks about why hungarian notation is a Good Thing, and how almost everyone uses it in a Bad Way.

I was rewriting the recruiting-rules for Eressea last weekend, and the rule there is that “for each peasant in a hex, players can recruit one person, except orcs, which can recruit 2 orcs per peasant, up to a limit of peasants/20, and if players want to recruit more, then the peasants in the hex are distributed evenly”.

The codes ends up looking a bit like when you’re trying to split your bills and you’ve been paying with 3 different currencies… I had a bug in that code, and only found it after I prefixed all my variables with p for numbers that represented peasants, o for numbers that represented orcs and d for numbers that represented the demand of a player – suddenly you see that you assign between them without the proper conversion.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s