So basically the only stuff in the class package is just a constructor, an AUTOLOAD method, and a couple of little utility methods.my $error_messages = MessageLibrary->new({ file_open_error => sub{"Couldn't open $_[0]: $!"}, bad_token => sub{"Invalid token $_[0] encountered on line $_[1]"}, bad_file_format => "Invalid file format", }); my $status_messages = MessageLibrary->new({ starting_parse_phase => "Starting parser...", generating_results => sub {"Generating results for element $_[0]"}, });
Update: While rereading this response, I realized there was an aspect of jeffa's point about not having to tailor error messages that I only partially answered. Although you can define error messages in the object constructor, the object also provides default handling for any method you might call. So you could do this: print $status_messages->undefined_msg($a_param, $another); and get a reasonable result. (You can also override this default behavior in the object constructor.)
In reply to Re: (jeffa) Re: is this a perversion of OO principles?
by seattlejohn
in thread is this a perversion of OO principles?
by seattlejohn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |