On 09.04.2008 07:32, Shin guey Wong wrote:
> Julian Leviston wrote:
>> A module is simply a place where you can store methods.
>>
>> Thus, you can include a module as a mixin in a class, and it will get
>> all the methods.
> 
> Yes, but we can achieve the same thing by inherit a class which will get 
> all the methods also.I know we can mixin multiple classes but only 
> inherit 1 class.
> If there is only 1 class/module, which we should use? create a module or 
> class?

If you need to instantiate it make it a class.  Everything that could be 
viewed as an "item" should probably be a class (where "item" could as 
well be a complex algorithm, see "command pattern").  A module on the 
other hand is more like a container for functionality that can be used 
in multiple places.  It can be either completely independent or - more 
common I believe - rely on some other methods for interfacing (like 
Enumerable relies on #each being defined).  Just look at modules defined 
in the standard library to get an idea how they are used (for example 
Comparable, Enumerable).

Kind regards

	robert