Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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 a log crumbles through the grate...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-11-21 23:21 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (312 votes). Check out past polls.