Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Re-Factoring: Philosophy and Approach

by poqui (Deacon)
on Nov 03, 2001 at 00:29 UTC ( #122910=note: print w/replies, xml ) Need Help??

in reply to Re-Factoring: Philosophy and Approach

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
  • Comment on Re: Re-Factoring: Philosophy and Approach

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-10-21 12:05 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (119 votes). Check out past polls.