Ron Jeffries <ronjeffries / acm.org> wrote: > >I noticed that RubyUnit is divided into one class or module per file. >Some of the modules seem to be included only once. This is typical in a number of languages. Within Unix files are your logical unit of organization. Many people map the logical units in the language (eg classes and modules for Ruby) onto files. Others are more willing to put 5 classes in one. There is no enforced connection between classes and files, but it is generally good to have any given class pretty much in one piece. (Rather than defined in one place and extended in 5 other files.) Personally I prefer to see each publically accessible interface (ie class or module) in its own file, but I have little or no preference about whether private classes are in the original or spread out. Of course as you discover reusable components, they are likely to spread into new files of their own... >The various files have a bunch of requires one to the other. The end user should be able to just load the file(s) that represents the public interface and all else should be imported. Note that there is some startup overhead for loading files. Normally I don't worry about that, but if you are writing something widely used or always loaded, there are times that it is worth either moving stuff externally to be autoloaded, or else inlining multiple files into one. >When using RubyUnit, it seems one has to write code like this: > > require 'runit/cui/testrunner' > RUNIT::TestCase.subclasses.each do | sc | > RUNIT::CUI::TestRunner.run(sc.suite) > end > >with lots of :: and random names. > >Is RubyUnit a good example of how to organized Ruby code? If so, >please discuss. If not, what is? (And discuss that.) I didn't find it difficult to use RubyUnit, but I did not look at the design/implementation closely enough to have a strong opinion one way or another. It allowed me to test what I wanted... Cheers, Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com