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

Re: When Is Dividing Code Into Different Subroutines/Packages Important?

by yosefm (Friar)
on Jun 14, 2003 at 10:26 UTC ( [id://265879]=note: print w/replies, xml ) Need Help??


in reply to When Is Dividing Code Into Different Subroutines/Packages Important?

It seems like your code is just the right thing.

Generaly, anything that could be useful to other programs should be seperated into a module even if currently you use it only once. A good example is the function login().

similarly some snippets of code, even if only used once should be separated into functions if they do something useful. Beside helping readability, this gives you the ability to reuse in the future.

Say you used the login process only once, making the program die on login failure. Now you improve your program and you want to allow 3 trials, or allow the user to use your program anonimously and login only for certain features etc. Are you gonna re-write the login snippet of code? or transfer it to a function? Better to put it in a function in the first place.

It's like filing your bills when you get them instead of stocking a big pile and have lots of fun sorting them at the end of the year.

  • Comment on Re: When Is Dividing Code Into Different Subroutines/Packages Important?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found