From: Gavin Sinclair Date: 2003-08-21T14:00:28+09:00 Subject: Re: One Module for one Class? [Damn this top-posting!] The CGI class in the stdlib (lib/cgi.rb) has heaps and heaps of methods. They are grouped into modules and mixed in. It seems a good way to do it to me, because it gives you a tangible way of grouping that is good for documentation. That assumes, of course, that you can justify so many methods in the first place. Some of the modules are explicitly justified because they are conditionally mixed in. QueryExtensions and HttpExtensions are not like this, however, and the user needn't know they exist. It's good from RDoc's point of view, though, because you don't have to look at millions of methods at once. Gavin > I suppose it depends on what kind of methods they are - for example, I > was very confused when I went looking for the File.exists? method in the > File class only to find that it was part of the Filetest mixin. I > suppose that class methods like those can be defined in a module. It > seems that all instance methods should be explicitly members of the > class, though. > > -Kurt > > On Thu, Aug 21, 2003 at 01:32:38PM +0900, Jeremy Whetzel wrote: >> Hello all! >> >> I'm planning on playing around with writing some sort of "package >> manager" for source based Linux distros or any of the BSDs. I'm >> thinking along the lines of Gentoo's portage system or the BSD ports >> system. I was toying around with modules with this idea, and I got to >> wondering something. If a class needs a lot of different methods, such >> as 30 or 40+ methods, and they're all very specific to that class, >> does it make sense to pull out a bunch of those methods and put them >> into a module and mix them in later, or should they be kept in with >> the class? For example, if I have an object that represents a >> software tarball, and that object has a number of attributes such as >> dependancies, reverse dependancies, comments, versions, etc, and then >> I have all the methods that go with it for fetching, configuring, >> building, resolving dependancies, etc, would it make more sense to >> keep all those methods out of the class or leave them in the class, >> even though it would make that class huge? >> >> I realize it's PROBABLY a matter of taste, but are there any good >> reasons to do it one way or another? >> >> Thanks for any input sent my way... >> >> Jeremy >> >>======= End of Original Message =======<