Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
After reading the Link from Albannach and musing over it all some more, I have to concur with others that Functions and Subroutines are good; but I had to think back awhile to remember why.
Others have covered most reasons, and another that comes to me is: modularity makes spreading out the work on a large project much easier. I started out programming in Basic and fortran, and my code was all spaghetti or straight top down. But I never modified the code, or even spent very much time debugging it. Later, the structured approach was the thing, and that brought along with it modularity. The next step was Object Orientation, which takes modules and makes them entities on their own. But I guess my point is, that making subroutines is really only useful if you find it so. For me, it became useful when my code got too big to grok in 1 chunk, then I broke it down into more grokkable chunks. Once it is starting to break into logical chunks, I would go all the way and have a lean control or main module that runs all the little subroutinesm, with pithy names. Then, if I find myself using a subroutine in several places with a only a slight variation, I look at making a function out of it. Its only one more step from function to its own program or module. "That that is, is... for what is that but that? and is but is?" Shakespeare, Twelfth Night, Act IV, Scene 2 "Yet THAT which is not neither is nor is not That which is!" Frater Perdurabo (pseud. Aleister Crowley), Liber CCCXXXIII, The Book of Lies In reply to Re: Re-Factoring: Philosophy and Approach
by poqui
|
|