Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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":



  • 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, 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, 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.
  • 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 meditating upon the Monastery: (5)
    As of 2021-04-22 22:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?