The Magic of Replaceable Parameters

Apart from hard-coding “Hello, world!”, another bad habit you may have picked up when you learned programming is constructing user-visible messages from parts: strings, numbers and other data, concatenated together.

For example, say that you had to show the user how many unread messages there are in a given mailbox. Let’s assume that mailboxName contains the name of the mailbox, and messageCount holds the number of unread messages. In Java, you might be tempted to whip up a user-visible message like this:

String message = "There are " + messageCount + " unread messages in mailbox '" + mailboxName + "'";

This is not the way to do it in an international application. Let’s find out why, and have a look at a better and much more future-proof way of doing it.
Continue reading