From: David Naseby Date: 2003-09-03T09:33:02+09:00 Subject: Re: OOP flavours - was Python vs. Ruby >From: james_b [mailto:james_b@neurogami.com] >I've been doing this sort of thing in my code, and after a while it >struck me as common sense, not purist theory. I find it goes a long >way towards cleaning up or avoiding procedural code where I >want OO, and >I find it easier to read. > I like this style too, and Ruby allows one to do it well via Mixin Oriented Programming (MOP?). The best library based example I've seen is in Amrita, where you extend your model class with Amrita::ExpandByMember, so amrita can render the object correctly. Similarly, you don't need to expand classes to predict there uses - for the example of IO printing flying around, you can extend on the fly: module STDOUTPrinter def print STDOUT.print self.to_str end end str = "helloworld" str.extend STDOUTPrinter str.print Its a fairly useless example in this case, but extend this to template based GUIs along the amrita lines, and mixin oriented programming shows its real strength. Not that I do it much in practice right now, but this message captures a lot about how I've been thinking in Ruby lately. Although I still don't understand it, I really like the ideas of "side-inheritance" as used by Matju: http://www.ruby-talk.org/13827 David.