Why do you want to write faster code? Is this just a general want, or is it an issue directly affecting what you need to accomplish? Efficiency is nice, but so is clarity. Personally, if I have the luxury, I will always sacrifice speed for well designed, clear code.

Personally, I wouldn't try to put more in one method. The more things a particular method does, the more likely it is for things to go wrong and for you to have maintenance issues. For example, if you have a method that establishes your database connection, you may think "ah, they're starting a session, so I'll just pack all of my other session initialization code in the db->connect method". All that is well and good, until the day that you need to establish the database connection without starting a session. Then what do you do? Rewrite your code base? Create another connection method and thus have duplicate code which needs to be synchronized? Keep the methods simple, and you'll be happier in the long run.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re: Method calls expensive?? by Ovid
in thread Method calls expensive?? by chorg

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.