Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: when to use subroutine

by mwah (Hermit)
on Oct 28, 2007 at 17:52 UTC ( [id://647716]=note: print w/replies, xml ) Need Help??


in reply to when to use subroutine

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://647716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-26 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found