On May 25, 9:47 am, Rick DeNatale email@example.com wrote:
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.