From: harshal Date: 2008-03-07T12:44:58+09:00 Subject: Re: Best practices for Ruby Meta-programming That's absolutely true. It reminds me Einstein's quote "Make it simple, no simpler" (or similar). I think 'Module'-related suggestion is a good beginning. Some of the best practices would still be valid from traditional OOAD. However, the place where Ruby differentiates itself from traditional programming languages is - Meta-programming. So I am expecting few 'new patterns' just because of meta-programming. I could not get any chance to look at the book 'Design patterns in Ruby'. Thanks. Harshal On Mar 7, 12:19 am, Avdi Grimm wrote: > On Thu, Mar 6, 2008 at 1:15 PM, James Britt wrote: > > Don't be evil. > > > Don't be stupid. > > So THAT's what I've been doing wrong all this time. Wish someone had > clued me in sooner. > > My concrete contribution to this discussion: > > Modules are your friend. When tempted to dynamically extend a class > with new methods, consider adding them to a module instead > (potentially a dynamically created module using Module.new). Then use > #include or #extend to add the module to your target. This has a > number of benefits, including: > > * Clients can clearly see which which methods come from your > extension vs. the methods that are part of the class itself, by using > Ruby's reflection. > * Clients can override dynamically created methods and still reuse > them with #super() - no need to resort to aliasing. > * A module can be re-used for either class-wide extension or > extending a single object. > > -- > Avdi