Hi --
On Sat, 9 Nov 2002, ahoward wrote:
>
> Rubyists-
>
>
> I've seen a few threads relating to this subject, so i decided to
> start one...
Interesting logic.... :-)
> What do people think is better style
>
> def Class
> def method
> Class.new
> end
> end
>
> VS
>
> def Class
> def method
> self.type.send :new
Why not:
self.class.new # type is deprecated, I think, and the 'send'
# is unnecessary
> end
> end
I don't think it's a style question; it's really a question of what
you want your method to do. I think much/most of the discussion on
this has revolved around the question of whether the behavior of the
core classes is optimal in this regard. When it comes to your own
code, you can do whatever's best in a given case.
[...]
> Sub-classing should always be reserved to _extend_ objects, old behavior
> should always remain - but may be added to.
Does that mean you would never override any method? That seems awfully
restrictive as a design principle.
David
--
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web: http://pirate.shu.edu/~blackdav