Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: $bad_names eq $bad_design

by pdcawley (Hermit)
on Dec 21, 2002 at 06:39 UTC ( #221585=note: print w/ replies, xml ) Need Help??


in reply to $bad_names eq $bad_design

Me? I worry about those global variables like $file, $html, %CONFIG and %REPLACEMENTS and find myself wondering if it wouldn't be better to make them attributes of the parser object:

sub ParserClass::do_global_replace { my $self = shift; while (my $token = $self->get_token) { $self->maybe_do_replacement($token); } return $self } sub ParserClass::maybe_do_replacement { my $self = shift; my $token = shift; if ($self->stack_matched) { $self->append_replacement_html; } else { $self->append_html($token); } return $self } sub ParserClass::append_replacement_html { my $self = shift; $self->append_html($self->replacement_html); $self->increment_replacement_count; }
(Admittedly, some of the utility functions are left as an exercise to the interested reader, I'm assuming that you have a parser per file and I worry that 'stack_matched' is still a bad name for the function, but I can't think of a better one at present. With these changes in place, your while loop becomes:
$html = $parser->do_global_replace->html;
I still worry mind. Now I'm worried that the parser is doing too much...


Comment on Re: $bad_names eq $bad_design
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2014-07-24 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (163 votes), past polls