The Best Solutions Are Non-technical
Mark Mzyk | March 29, 2009
I recently had an issue where I was working on how some text was displayed on a site. Part of the text was user supplied and part of the text was not. As an example, it would be something like this:
Book: Title
The title would be supplied by the user, but the product type would not be, it would simply be selected from a list. This information would then be available to other users in various languages. Since the title was user supplied, it was clear that nothing would be done to translate it. Initially it was decided that the product type (book, in this case) would not be translated, but would be left in English.
At a low level this code interfaced with gettext. There was some entanglement between the code that displayed the product type and gettext, which meant if a user where to view the page in a non-English language, then the product type would be translated. But the decision had been to not translate it.
I was left with three options:
- Do nothing – let the product type translate.
- Copy the code to display the product type so that it wasn’t using gettext.
- Rewrite how the application used gettext so that the product type code and the gettext code weren’t so wedded to other.
There were problems with each option:
- This wasn’t the decision that was wanted.
- This was easy, but now it meant the product type code existed in two places, and any updates would have to be applied in both places. I could easily see it happening that an update made to one place wouldn’t be applied to the other. This solution bothered me because it violated DRY.
- This involved a massive rewrite that would solve the problem, but would take the most time and touch a lot of the application.
I went with option one: do nothing – let the product type translate. This meant I had to change no code, so it was the quickest and easiest to implement, while also not violating DRY. This did go against the decision to not translate the product type, but after bringing up the issue with all concerned parties, it became clear that having the product type translate wasn’t a big issue.
The issue was resolved in the best possible way not because clever code was written, but because a non-technical solution was found. Often, the first impulse for any developer (myself included) is to start typing and to stubbornly plough through any technological issues that arise. However, sometimes the best way forward is to take the time to stop and ask people to consider their decision, because going a different direction might be easier and better for everyone.