Tuesday 29 April 2008

Localizing "file(s)" using ngettext

We all know the problem: We have a list of files, and we want to have a label that indicates the number of files.

In English, it's quite straightforward:

Label1.Caption:=IntToStr(FileCount)+' file(s)';

The usually internationalized version looks like this:

resourcestring FileCountStr='%d file(s)';

Label1.Caption:=Format(FileCountStr,[FileCount]);


Looks easy, right? It's not. In Polish, there are three plural forms:

1 plik
2 pliki
5 plików

Even french is different with regard to plural forms. In English, we use the plural form for zero (0 files, 1 file, 2 files), whereas the french use singular (0 fichier, 1 fichier, 2 fichiers).

With GNU gettext for Delphi, the solution is quite straightforward:

Label1.Caption:=Format(ngettext('%d file','%d files',FileCount),[FileCount]);

Ngettext() will automatically select the right plural form in the local language, even if there are 1, 2, 3 or 4 plural forms, and the translations tools (poedit and kbabel) provide good features for the translator to specify each plural form in good ways.

Saturday 26 April 2008

Agile is just a step in the right direction

Whenever I hear the term waterfall model, I start wondering: Which organizations would actually do that? Who has ever done programming without changing the specs along the way? Maybe the contracts or formal specs weren't changed during the project, but I still lack to see a big system that was actually programmed exactly as it was originally specified.

My first experience with XP was, that somebody put words on how things were actually done, added a few more techniques, and wrote a book. I really enjoyed that. Then came Agile as a term, because Scrum, RUP etc. were all trying to fix the same problem, and the Agile Manifesto. Brilliant.

But today it seems that something is going wrong. I see more and more Scrum fanatics, which are actually trying to discuss "is 14 days or 21 days the best iteration length?" That's actually a violation of the agile manifesto: You need to respond to change, and focus on people and interactions, instead of focusing on a process.

Looking retrospectively at the last many years, I can only conclude, that it's not a question of choosing a method for developing software. It's about being good at understanding and managing software projects.

I don't think that "Agile" is the last buzzword in software development. To some people it has already gotten the meaning "less predictability", whereas to others it means "Iterations". Others immediately think "Scrum". To me, Agile means better management. One day, someone will write a new book, with a new title, and that title will contain a new buzzword.

Thursday 24 April 2008

Delphi usage increases

I don't trust statistics that I didn't forge myself, but I found this statistics page interesting.

Wednesday 23 April 2008

Bloat grows more than PC speed

According to Infoworld, Microsoft Office is getting more bloated.

Bloat is not a problem by itself - everything that is written in a high level language is basically bloat. The amount of bloat is determined not only by the programmer, but also by the decision process that leads to the next product release. How important is performance in the sales process? Does the organization provide an environment that makes high-performance solutions possible?

If you want to create software that has good performance, start by asking your boss if he wants the application to perform well. If the answer is yes, the next question will be "how well?". Be prepared to answer questions about costs and benefits.

If it doesn't make economically sense to remove bloat, you need to spend your time on something more valuable. Fortunately for me, I work in a company that considers the user experience to be very important :-)

Thursday 3 April 2008

SYLK - storing spreadsheets in your source code repository

How do you collaborate with other programmers using a spreadsheet, if that spreadsheet needs to be stored in your source code version control repository? A good choice is the SYLK file format. It is easy to read in a text editor, is compact, supports merging of multiple edits or branches easily, and it supports formulas (tested with OpenOffice.org 2.4).