Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I am going to advocate for creating each method name explicit
for the reason of future change. If you find that method
needs to be changed it will already physically exist and
you will just have to modify it. Now I know it isn't a big deal
to add a method in the future, but if you can do it at this
stage I think you will further ahead in the long run.
I think AUTOLOAD is a bad way to go on this one. I had
a discussion with some other proprammers recently about
using AUTOLOAD on something similar and it frowned upon
for maintenance and speed issues.
If there is code already using these methods I would also
suggest code like this:
sub add_company { my ($self,$data) = shift; $self->gen_add($data,'company'); } sub add_financial_diary { my ($self,$data) = shift; $self->gen_add($data,'financialDiary'); } sub gen_add { my ($self,$data,$table) = @_; my $return = $self->_generic_insert( $data, $table ); $self->{ _dbh }->commit if ! $self->{ _error }; return $return; }
This code would allow you move the gen_add method into
another inherited class if you need to and not break the
code. By having $self and $data available you
also cut down on code that needs to be written if you
determine the method needs to not call the gen_add method.


In reply to Re: Refactor method calls or not? by trs80
in thread Refactor method calls or not? by Ovid

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 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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2021-05-12 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (129 votes). Check out past polls.

    Notices?