One thing I don't like with classless objects is, that you can't easily temporarily patch/overwrite a method. In my tests I often do the following :
# (test for WWW::Mechanize::Shell) { my $called; local *WWW::Mechanize::get = sub { $called++; }; ok( $shell->foo() ); is( $called, 1, '$shell->agent->get was called one time"); };
This is relatively clean and dosen't require much mucking to find out the package of the sub I want to patch. A classless object would possibly have its subs in some package which is dynamically generated, which makes patching/overriding harder unless I fall back on Hook::LexWrap (and even then ...)
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
In reply to Re: When to use prototype inheritence?
by Corion
in thread When to use prototype inheritence?
by bsb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |