|Perl Monk, Perl Meditation|
When do you function?by zdog (Priest)
|on Dec 27, 2000 at 08:38 UTC||Need Help??|
Today, I tried to write another Perl program (first one in a while tho). I spent quite a bit of time on it. But anyway, that doesn't matter, what matters (at least for this post) is what I began to debate about afterwards: When do I and when should I put my code into functions?
After thinking over it a while, I came up with several reasons why people (or maybe just me) should use functions at all:
Each of these reasons has some validity and could very well be considered for use in each of those situations, however, each also has some disadvantages which I also pondered about:
With all of this in mind, I find that functions can help in many ways in programming in general, however, they should only be used when they are best option. In conclusion, before one puts code into a function, they should consider loops, comments, and all other possible means of achieving their goal and weigh the advantages and disadvantages of each and not making functions just to make functions. (At this point you say, "Duh, zdog! Isn't that what you should do with everything in life? Some major breakthrough... Geeze, and I just wasted a whole 1 minute and 34 seconds* reading this.")
This is what I think on the topic. What are your thoughts about it? When do you use functions?
Zenon Zabinski | zdog | Zenon.Zabinski03@students.bcp.org
*Disclaimer: The actual time it takes to read this post may vary.