moot has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|