On May 25, 9:47 ¨Âí¬ Òéãë ÄåÎáôáìå ¼òéãë®äåîáô®®®Àçíáéì®ãïí÷òïôåº > On Mon, May 25, 2009 at 8:53 AM, trans <transf... / gmail.com> wrote: > > > On May 25, 7:24 ¨Âí¬ Áîäù ¼áîäãèáæï÷ò®®®Àùáèïï®ãïí¾ ÷òïôåº > > >> Generally I think using nested classes for real helper classes that can conceptually only be for use with the parent class is a useful way of avoiding namespace clutter. > > This is the only really good reason I've found for doing so. > > I can't agree with that, the value of namespaces is orthogonal to > ideas like 'private' classes, in fact, I think it's more valuable when > the names are intended to be used outside of the implementation of a > class, it helps whenever two things end up competing for a name. > > For example in my new icalendar gem, I use nested name spacing so that > I can have an Event class, and a using application can have it's own > Event class(es), maybe one might be a database model. I'm not seeing how you disagree. The example you give is seems like a fair example of the reason stated. I take it you have an ICalendar class as the top namespace? Then Event is being used by it, even if in a round about way --and even if the class could be used independently, it was designed for use in this context. > I've seen, and been involved with too many languages which suffered > from the lack of Namespaces, sometimes adding them in later versions > of the language, not to appreciate the value. > > It really isn't an issue of containing a class within a class, it's an > issue of containing names within name spaces. Sure, but the question translates to Ruby as a question of practice, i.e. typically one should use modules for name spaces, and hence the question arises, when is using a class as a name space a better idea? > And I do other things like putting a module which I've used to > refactor a large class into separate files inside the namespace of the > (main or only) class which includes it.http://github.com/rubyredrick/ri_cal/tree/master That's cool. Your making class components. Still falls well into the stated reason --the class is making use of the modules. T.