Skip to main content

Applying the lesson of magic numbers

Posted by joconner on November 29, 2004 at 10:40 PM PST

I've been actively helping developers write good Java programs for years. My experience is primarily in internationalization and localization. Naturally, I try to teach best practices to those I mentor. I've always wondered why my comments regarding i18n (internationalization) come as such a big surprise to other programmers. OK, maybe "surprise" is too strong. However, i18n is too frequently a new subject to many coders, designers, and even architects. Why aren't some i18n best practices taught to every programmer at an earlier point in their career...in undergraduate computer science courses for example?

I remember one of the very first lectures of my Computer Science degree. One of the tips was "avoid hard coded, magic numbers in your code." My question is why didn't anyone teach this rule for text?

The linked article ponders this question. Don't read and think that this is the way to prepare for localization. It most definitely isn't. However, it is a start, a much better start than what any typical undergraduate computer science student learns.

Article is here:


http://www.joconner.com/javai18n/articles/MagicNumbers.html

Related Topics >>