Many thanks for your thoughtful answers, Tobias. I'm going to split my follow-up questions into a couple of messages, so that the different issues are in reasonably short posts. Tobias Peters wrote: >> > >> > 1) Is it possible (or even sensible) to override LogLine.new so that it >> > returns an instance of the appropriate subclass? I've never liked the >> > Java-style LogLine.getInstance(args); it seems unfair to make >> > programmers keep track of whether you're using a Factory internally or >> > not. >> > He can add a singleton method > def LogLine.new(logline_string) > # return subclass instance if apropriate > # if not, create a plain LogLine: > super(logline_string) > end > >> So creating a (static) method LogLine.create or something like that is >> probably the way to go. > > This is better than overiding new because programmers expect > SomeClass.new.class == SomeClass Should programmers really depend on that? It would seem that if SomeClass.new returns a subclass of SomeClass, then it should always behave as a SomeClass. Ergo, no harm done. Could you give me an example of a situation where overriding new to return a subclass wouldn't work? Every example I can think of turns out to be either bad subclass design or an encapsulation violation on the part of the user of SomeClass. That's not to say I think that overriding new is a good idea yet. I'd never suggest this in Java, for example; it would cause heart attacks on the part of the language designers and brain aneurysms for many Java users. But since Ruby is so much more flexible, I'm trying to see how far I can bend it. :-) William