From: Martin K. <mar...@fe...> - 2007-10-05 08:07:00
|
Hi there, As Rob pointed out, most new() methods currently do what I have proposed (but at some other place). As there's nobody here telling me that calling new() every time is important, I'll just implement the proposed alternative. Im not going to work over the whole SOAP-Lite package to make this consistant, though - at least not now. Thanks for your comments, Martin Am Donnerstag, den 04.10.2007, 12:44 +0200 schrieb Martin Kutter: > Hi there, > > around line 2250 in SOAP/Lite.pm, there's the package SOAP::Client. > > It creates a bunch of setter/getter methods, like this: > > *$method = sub { > my $self = shift->new; > @_ > ? ($self->{$field} = shift, return $self) > : return $self->{$field}; > } > > I stumbled across the first line of these methods today, when writing a > loopback test transport backend: It calls the transport backend's new() > every time one of these methods is called, regardless of whether it's > been called before.n > > In my opinion, this introduces two misbehaviours: > > a) the constructor new() is frequently called as an object method - > which is a perlish, but nonetheless bad habit > > b) all initialization (or whatever a user has done to the transport > layer between calling new() and the next method call) is lost, as > there's alway a fresh method there. > > This means that users cannot set LWP::UserAgent's characteristica by > calling $soap->transport->some_lwp_method(1);, because send_receive (at > least in the HTTP transport class) might call $self->endpoint, and thus > operate on a new object. > > Are there any reasons for SOAP::Client behaving like this ? If not, I'd > change the line to > > my $self = ref $_[0] ? shift : shift->new(); > > which also guarantees there's a valid SOAP::Client object, but does not > override existing ones. > > This might induce subtle side effects, even though there's no effect on > the test suite. > > Any opinions ? > > Marti > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Soaplite-devel mailing list > Soa...@li... > https://lists.sourceforge.net/lists/listinfo/soaplite-devel > |