http://www.perlmonks.org?node_id=928112


in reply to OO Design question.

From scanning the code, it looks to me you're analysing it up to three times. That just feels wrong to me, whether you're using OO or not. (And up to two times, you create an object, call a method on it, then the object is discarded).

Also, you set a severity in $self, but isn't the severity already implied by the type of object returned from parse_body?

I'd probably make it like:

sub analysis { .... returns one of 'critical', 'harmless', 'unseen'; } sub parse_body { my $self = shift; $self->set_severity(analysis($self->mailbody))->severity; } sub set_severity { $_[0]{severity} = $_[1]; # Substitute your favourite OO implemen +tation $_[0]; } sub severity { $_[0]{severity}; }