From: "David A. Black" Date: 2009-11-15T03:21:41+09:00 Subject: Re: Naming conventions -- was: Re: DRYing a Regex Hi -- On Sat, 14 Nov 2009, Marnen Laibow-Koser wrote: > James Edward Gray II wrote: > [...] >>> Even Apps Hungarian is not a great idea in OO code. Instead, just use >>> the type system, so that distance would be a Kilometer object and >>> correction would be a Foot object. Kilometer.+(foot) could then either >>> raise an exception or invoke a conversion. >> >> I would like to see us move away from considering classes to be types at >> all in Ruby. Who knows what modules an object has mixed into it and who >> knows what singleton methods are defined on it. > > Do you make much use of singleton mixins or singleton methods in your > code? I know I don't. I write class methods sometimes (I know those are singleton with an asterisk next to them, but still), and I think that extending core objects with modules is a frequently overlooked and very powerful alternative to reopening core classes and adding methods. This kind of thing: class String def method_I_need_once_or_twice ... is almost always overkill. It's sort of the core-functionality counterpart of using global variables. Extending an object is a much more precise operation -- and has the additional merit, I find, of really making you think about whether it's worth bothering to the extend the object instead of working with what the object can already do. David -- The Ruby training with D. Black, G. Brown, J.McAnally Compleat Jan 22-23, 2010, Tampa, FL Rubyist http://www.thecompleatrubyist.com David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)