On 10.05.2007 15:25, Enrique Comba Riepenhausen wrote: > > On 10 May 2007, at 15:14, James Edward Gray II wrote: > >> On May 10, 2007, at 8:10 AM, Enrique Comba Riepenhausen wrote: >> >>> Thanks a lot James, I think this clarifies (at least from the newbie >>> point of view) a lot of the power under the hood in Ruby! >> >> Sure. >> >>> I'm now thinking where to include this in the Wiki. >>> >>> Any idea? >> >> I feel it could be part of a discussion of the factory pattern. It >> fits well there, I think. >> >> James Edward Gray II >> > > Yep! Included! > http://www.rubypatterns.org/doku.php/gang_of_four_patterns:factory_method > > By the way, feel free to edit the wiki in your liking. I actually set it > up as a collaborative project where we all can share our knowledge in > the Design Pattern implementation and discoveries in Ruby ;) I'd go even further and point out that *every* class[1] in Ruby is a concrete factory - maybe even at the start of the article. In the most general way the interface is new() i.e. what you would call a "default constructor" in other languages. Few know that classes usually also provide method #allocate to create an instance of the class but without invoking #initialize. So that would be the second factory method that all classes support. :-) Also, you can create any number of additional factory methods on a class, if you wish so. And finally, since there are no interfaces in Ruby the pattern might be less obvious, even if implemented "properly", i.e. with concrete creation methods. (I think you do mention that on the Wiki already.) Kind regards robert [1] excluding classes that do not support #new.