Tag: best practices

Why The Joel Test will save your life

If you haven’t seen it, it is Truth. Learn it, memorize it, evangelize it.

(maybe)

The Joel Test

  1. Do you use source control?
  2. Can you make a build in one step?
  3. Do you make daily builds?
  4. Do you have a bug database?
  5. Do you fix bugs before writing new code?
  6. Do you have an up-to-date schedule?
  7. Do you have a spec?
  8. Do programmers have quiet working conditions?
  9. Do you use the best tools money can buy?
  10. Do you have testers?
  11. Do new candidates write code during their interview?
  12. Do you do hallway usability testing?

We’re going to talk about #2.

Build

Let me paint you a picture:

You need to build two versions of app, one for French Guiana and one for France. Also, your app uses google analytics, google maps and some kind of crash reporting thing, all of which require tokens to access their respective APIs.

Being the Smart Developer you are, you don’t check your tokens into source code, because that would expose them to anyone who had access to your repository.

Instead, you edit the appropriate config files and add the token strings to the right fields. Your software repository ignores the changes to your config files so you don’t accidentally check them in.

You build your app for your default country, France, upload it to the app store and so on.

Now it is time to build it for French Guiana. Fortunately, everyone there speaks French, so no need to worry about translating anything (we don’t need no i18n!!1), so we just have a few changes…

  • Bundle ID
  • Google analytics tracking id
  • Google maps api key

If we don’t use a different analytics tracking ID, it will be difficult to determine usage for each app. Also, we want to keep the map’s api key separate so if one app’s traffic spikes, it won’t affect the other app.

One step

To satisfy the Joel test, we should be able to build with one step. This means ONE command.

One easy way would be to use ISO 3166 country codes.

France

app-build --locale=fr

French Guiana

app-build --locale=gf

However we do it, it should not involve any manual steps to complete. This will decrease the chance of making any mistakes, shrink the learning curve for new developers, and ensure that every deployment is done the same way.

Adding defensive sanity checks

I recently needed to make a set of several favicons, so I went to the web to see if anyone had a script I could borrow steal.

Sure enough, I found one written by Joshua McGee: “Create a favicon with ImageMagick” (not reproduced here for copyright reasons).

It was a simple enough script, just a series of escaped commands. I noticed, however, that it assumed a few things:

  • An image file was specified on the command line,
  • The image existed, and
  • Imagemagik was installed.

In other words, the script was not developed defensively. This makes sense: it was just a bang-out.

The script had no inline documentation, and if a favicon file that already existed in the current directory would be silently overwritten—not good.

I’m clumsy: I delete and overwrite files all the time, so I could use a little help. Maybe I can tidy up the script? (more…)