This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Namespaces or Classes
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
The few, the proud, the brave, who have played with Smalltalk/X may recall that they have a novel approach to Namespaces. Long ago, long before the rest of the Smalltalk community even talked about namespaces, they had implemented private classes. So they just use these as Namespaces. I've tooted this horn before. I think they do it right.
I've got this back burner project I've been noodling about and have been playing with a little bit as of late. We do more-than-the-average locale and internationalization work. Our current UI runs in 17 languages and this list is always growing. I'm tired of creating Locales. I don't like the Locales I create, I make mistakes. I don't like the current Locale model and implementation either.
So there's this thing called Common Language Data Repository (CLDR) and my intent is it codify that. In fact I'd like to take a page from the same book that turned exceptions and announcements into Class based entities.
One of the interesting thing about CLDR is that they use inheritance in their data model to dramatically reduce bloat. For example, there is a generic ENglish locale description. And then there are variants for CAnada and US and other territories. Since most of these modify some minimal amount of attributes of generic english, they inherit from the generic local. There's a "root" that is the base of everything. So one might have a hierarchy that is described as:
root
en
en_us
en_us_posix
Obviously, we throw all of these "classy" locales in a namespace of its own. Then we create a Root class. And an EN subclass of Root. And a US subclass of EN. And Posix a subclass of US. Leaf classes will tend to have minimal overrides of parent methods.
Hopefully, you've seen the problem with this already. It turns out that other languages would have US subclasses as well, in particular ESpanol and HAWaiin. So, for now, I'm stuck making class names like:
Root
EN
EN_US
EN_US_POSIX
If VisualWorks used the same model as Smalltalk/X though..... I'd've been home free.