From: Raul Parolari Date: 2007-11-24T09:57:42+09:00 Subject: Re: Composition: Build objects from other objects Thufir wrote: > Thank you for the information. > > I was looking at mixins-in-ruby/> and it has a good discussion and explanation of > "include" versus "extend" for mixins of modules, which I find quite > informative. Bit off topic, but kinda related. Hi, Thufir I browsed the site, and I understand that it is very useful for somebody coming from Java to begin to picture what 'include/extend' are in Ruby. However, beware that this kind of information is useful and 'dangerous' at the same time if taken literally; eg, the example it gives of a Module hardcoding the class name (that is using it) is a bit.. eery (although I understand that he is just trying to show the mechanics of interaction module-class). In Ruby, a Module of course has no preconceived notion of the classes using it; but, at the same time, if it needs to 'talk' to the class using it, it can (see the humble Enumerable module; you write a class including it, you define 'each', and suddenly.. you get a bounty of methods free; the module is in fact calling your 'each'). Not to mention Rails, were the interaction between Classes and Modules becomes surreal (modules injecting code into classes at the moment that those classes are being created..). So, perhaps take that site with a grain of salt, and, when you have a chance, try a good Ruby tutorial on Classes/Modules; a great thing in Ruby is that one can read and test at the same time with irb even the most complex inheritance scheme (so one does not get asleep in an 'ocean of abstractions' :-). Regards, Raul -- Posted via http://www.ruby-forum.com/.