Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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


Comment on Re: OO Design question.
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928112]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-12-29 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls