Please help me to identify whether I should stick with AUTOLOAD or should I move to Class::Delegator class.
Three thoughts come to mind reading your post:
That reason could be because of your organisation rules: how would a bunch of strangers on the internet know those?
Or the reason could be efficiency or ease of maintenance of the implementation: trading a single simple subroutine for 150+ subroutines doesn't seem to be a good reason.
Or perhaps you think that what you have is not OO enough: allowing such academic criteria to override your own assessment is a very bad choice.
I might make one change though. Assuming that only one type of connection will be used in any given application:
sub AUTOLOAD { my $connection = $device->getConnection(); { no strict 'refs'; *{ __PACKAGE__ . '::' . $methodname } = $connect->can( $method +name ); } return $connection->$methodName (..); // when called for getVersio +n, $methodName will become the "getVersion" }
Now, the AUTOLOAD process will only be used the first time a method is called, which could effect a nice performance boost if many calls are made to some methods.
In reply to Re: Choosing between AUTOLOAD vs Delegation
by BrowserUk
in thread Choosing between AUTOLOAD vs Delegation
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |