Greetings. This is not strictly a perl question, but I imagine answers will be perl-idiomatic, so it is relevant to this forum.

I have a module Lookup::Remote implementing a class with a class variable $RemoteURI that is intended to be configurable from calling code via accessors. The main piece of calling code is itself a class (User). OO principles dictate that any users of the User class need not concern themselves with the internal implementation of User, including that it uses Lookup::Remote.

The User class is not the right place to initialise the $RemoteURI variable since it has no access to configuration parameters (only the application-level code has that, via AppConfig). Likewise for the Lookup::Remote class.

Any app-level user of User has to be able to set $RemoteURI, but that obviously means the application has to know that User requires Lookup::Remote.

So my question is how should I approach allowing application code to set $RemoteURI without necessarily knowing the implentation of User, and thus use()ing Lookup::Remote itself, or passing the remote URI value to instances of User (which also breaks the boundary of what the calling code needs to know about User's implementation)?

For what it's worth, the Lookup::Remote library is just one class used by User - the calling code does not (need to) know from where the User's values are populated.

Update: feel free to point out ways this design might be broken. If you have a neater approach, so much the better!

--
Now hiring in Atlanta. /msg moot for details.


In reply to OO, Library Configuration and Class Variables by moot

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.