aidy
July 7, 2008, 1:41pm
1
Hi,
Could anyone please tell me what the difference would be of inheriting
a class versus passing that class\object through the initialize
method?
class ErrorBox < Box
end
v
box ||= Box.new
class ErrorBox
def initialize(box)
end
end
And why would I do one over the other?
Thanks
Aidy
aidy
July 7, 2008, 2:35pm
2
On Jul 7, 7:37 am, aidy [email protected] wrote:
v
And why would I do one over the other?
Thanks
Aidy
Try googling “inheritance vs delegation” and “inheritance vs
composition”
Here is a discusin from Perl (http://www.perlmonks.org/index.pl ?
node_id=278375), looks to cover the
area pretty good
Artima has a lot of good info, here is an article on inheritence vs
composition (similar to delegation),
http://www.artima.com/designtechniques/compoinh.html
cheers