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?