Keep It Simple, Stupid | |
PerlMonks |
Re: when to use subroutineby mwah (Hermit) |
on Oct 28, 2007 at 17:52 UTC ( [id://647716]=note: print w/replies, xml ) | Need Help?? |
convenientstore: Is there a hard rule regarding when to use subroutine? No. There hasn't been one and there won't be one anytime soon. How does one know if using subroutine is better than not using it? This depends entirely of the absolute knowledge of the person in question. There are aspects of efficiency, comprehensibility, maintainability etc. A subroutine is just one of the means used to transfer a concept into a technical thing, a code or program. Can you guys share(or at least point me to right direction or URL) your rules or where you learned when the best time to use subroutine? I learned to use subroutines just naturally, by *not* using them in the beginning. If your knowledge evolves over time, your conceptual view of the optimal structuring and transferability into code starts to include "subroutines", "records" (structured data), "modules" and all these things. Don't try to imitate things which you didn't really internalize. Just don't use any subroutine in your own code until it gets crystal clear for you to do so for a reason you like ... Regards mwa
In Section
Seekers of Perl Wisdom
|
|