http://qs321.pair.com?node_id=624203


in reply to Re: SOAP Modules (OO or not?)
in thread SOAP Modules (OO or not?)

Maybe I didn't explain too well, consider this plain module I use for handling SOAP requests...
package SOAPServer; use strict; use warnings; sub myfunction { my $class = shift; my $self = {}; bless ($self, $class); my $one = shift; my $two = shift; $self->{one} = $one; $self->{two} = $two; return $self; } 1;
Is that okay on it's own, or should I create a new() sub to do the bless'ing? I'm sure it's more a question of "best practice" than anything else.

I'm just thinking that I'll soon have lots of sub's in the one module, so it'd obviously make sense to move the bless'ing stuff into a seperate private sub.

In the future one sub may indeed call other local subs, so if nothing else, blessing it to the class would make my code nicer to read with $self->fun2(), and let me structure the object nicely, and pass the whole thing back to the calling SOAP client.

Thoughts?