in reply to When to use prototype inheritence?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: When to use prototype inheritence?
by bsb (Priest) on Sep 08, 2003 at 09:23 UTC | |
by simonm (Vicar) on Sep 08, 2003 at 16:13 UTC |