Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I know you disagree, that is why you did yours differently.
I am curious, why an OO module should not have an external configuration file. By having a separate configuration file you can access the configuration file from utilities outside of the modules when you are doing something small and other languages can read them if they are in a digestable format. I use the same connect handling mechanism and dynamicly determine which conf to use based on directory location, this avoids be from having to hard code anything inside of the modules themsevles, which I thought was the real point in OO, not to disallow any external information, but to promote external information for configuration and settings. The code I have allows for BOTH from a configuration file and setting the parameters inside of the application. Here is a trimed down constructor I am using in a current project.

sub new { my ($class) = @_; my $self = {}; bless $self , $class; my $config = { dbd_user => 'user', dbd_driver => 'mysql', title_text => 'TITLE HERE', database => 'my_database', dbd_port => '3306', style_sheet => 'default.css', dbd_password => 'my_pass', smtp_server => 'mytrusted.mailserver.com', dbd_hostname => '127.0.0.1' }; $self->_debug(1); $self->assign_to_object('conf',$config); # $self->error_to_log(Dumper($self)); return $self; } sub assign_to_object { my ($self,$prefix,$hash) = @_; foreach my $column (keys %{$hash}) { my $method = "$prefix" . "___" . "$column"; $self->$method($hash->{$column}); } }
This is all part of a much larger framework that I am still refining. I some of this makes no sense unless you know more about the rest of the framework, I will have to save that for another post.

In reply to Re: Re: Re: DBIx::Simple by trs80
in thread DBIx::Simple by Juerd

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found