Seems like a good idea to me, for what it is worth..

Using an inheritance trick, polymorphism, you could subclass each of the specific MessageLibrary objects so that instead of having different methods in one class, you have many classes with a common overloaded method:

my $file_error = Error::FileOpen->new(); open MYFILE, $myfile or die $file_error->handle($myfile);
But, as far as i can tell you with my current knowledge of such problems - all you are doing is moving code from one position to another, you aren't eliminating code.

I think i'd just rather use:

open MYFILE, $myfile or die $error_messages->generate_message( 'file_open_failed', $myfile );
because you don't need to worry about adding code to tailor an error - unless you really need that, don't worry about it. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)

In reply to (jeffa) Re: is this a perversion of OO principles? by jeffa
in thread is this a perversion of OO principles? by seattlejohn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.