From: James Edward Gray II Date: 2009-11-15T02:06:56+09:00 Subject: Re: Naming conventions -- was: Re: DRYing a Regex On Nov 13, 2009, at 10:39 PM, David Turnbull wrote: > On 14/11/2009, at 15:21, 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. A class, which is what people traditionally take for the type, is just one piece of an object's identity. > > I would still look immediately to the class of the object in order to find out what it's supposed to do. From there, the class definition will probably list it's module inclusions prominently. Sure, it's definitely part of the picture. > As a vim user, with very limited interactive debugging, my primary exploration technique will usually consist of at most a couple of 'obj.methods.grep' calls followed by grepping ~/gems which seems to emphasize the actual reading of the source for object identity info. Your use of grep() for methods catches a lot of things a class definition might not tell you. > I'm curious what you think the most correct way is to discover object identity. Well, if we just mix modules into objects as I recommended in my previous message, Ruby's type system just naturally handles all of the details. >> o = Object.new => # >> module Magical >> def inspect >> "#" >> end >> end => nil >> o.extend(Magical) => # >> o.is_a? Object => true >> o.is_a? Magical => true >> class << o; self end.ancestors => [Magical, Object, Kernel] James Edward Gray II