Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: OO Design question.

by JavaFan (Canon)
on Sep 27, 2011 at 16:15 UTC ( #928112=note: print w/replies, xml ) Need Help??

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}; }

Replies are listed 'Best First'.
Re^2: OO Design question.
by Anonymous Monk on Sep 29, 2011 at 14:12 UTC
    I also don't like repeated calls to the analysis method hence my original post.

    Severity is sort of implied from the returned object but its not a one to one mapping so I've left it as is.

    Basically I'm trying (and failing) to keep the balance between KISS and elegance (would they were the same).
    Thanks for your post.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928112]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2018-06-22 09:31 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (123 votes). Check out past polls.