in reply to Method calls expensive??
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Ovid) Re: Method calls expensive??
by Pin (Novice) on May 05, 2001 at 02:08 UTC | |
|
Re: (Ovid) Re: Method calls expensive??
by chorg (Monk) on May 05, 2001 at 02:06 UTC |