which you would later turn into a dispatch tableif ($category_id eq "all") { push @all_matches, SomethingAll(...); } elsif ($category_id eq "subj") { push @all_matches, SomethingSubj(...); }
OO not required. When deciding which function to call requires something more complicated than a simple string comparison (key lookup), you'll benefit more from using object-oriented-programming.my %dispatch_table = ( all => \&SomethingAll subj => \&SomethingSubj _default => \&SomethingDefault ); ... my $callback = $dispatch_table{$category_id} || $dispatch_table{_defau +lt}; push @all_matches, $callback->(...);
perl Moose Strategy Design Pattern -> https://secure.wikimedia.org/wikibooks/en/wiki/Computer_Science_Design_Patterns/Strategy#Perl
In reply to Re: How to implement a Design Pattern/ Strategy??
by Anonymous Monk
in thread How to implement a Design Pattern/ Strategy??
by jonc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |