From: "Ara.T.Howard" Date: 2005-07-26T00:31:00+09:00 Subject: Re: Using a class namespace for subclasses On Mon, 25 Jul 2005, Trans wrote: > > > Ara.T.Howard wrote: >> >> i'd do >> >> module HashTable >> class Ordered; end >> class Sync; end >> class Static; end >> end >> >> cheers. >> > > You would keep it seperate. Why so? > > T. i dunno - some namespaces aren't likely to get polluted because there not that often used. Hash, however, has got to be one of the top candidates, along with Array, for sticking stuff into. that reminds me, what i did for arrayfields, which adds a bunch of methods to Array __instances__ is something like module ArrayFieldable def foo ... ... end def bar ... ... end end class Array def fields= fields self.extend ArrayFieldable ... ... end end so Array got polluted with only one method but certain Array instances get tons of methods clobbered when ArrayFieldable is included. by sticking your classes into a separate module one would only need class Hash include HashTable end or, selectively (i do this alot) class Hash Ordered = ::HashTable::Ordered end and then one could ho = Hash::Ordered::new yet any problems/nameclashes could be solved by just using ho = HashTable::Ordered::new so you can have your cake and eat it too. i guess it seems easier to bundle up names and allow people to import than to inject them into a class and make people pull them out in the case of problems. 2cts. cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================