Functions vs Scripts - Unix Bash Programming -


I am quite new about programming (one year with java) and about a very new session (about six weeks). I wrote a small application that does some things, and it is entirely the idea of ​​scripts not a function. I know that I can have a file with all the functions but why and / or when.

For example, I have a script called getID, which calls the "validateID" script to ensure that the ID is valid 3 numbers pre 827 395 148), then for a specific ID, a " ID "and if the ID is valid and found, then it returns the correct.

Then I have another script which is called getID2 which validates the ID and returns the correct ID if it is not found.

I've got getopt command recently where i can getID -f say true if to get back and getID -n return to true if not got or i get a function getid write (I can get 0) and if I get, then gives 1.

I am currently trying to write applications with better logic. I will accept any advice for any part of the program, but I would really like to know when I should use the function and / or when I should use the script below the specificity for the program, thanks in advance!

Special - Application is a small reporting system where I have a list of IDs, names and scores. I can view, edit, update or delete anyone based on their ID.

As a general rule, you should only create a whole new script for something when it is important The standalone utility is that if the only reason for its existence is to be called by the main script, then it should have a function in the main script. Edit: If a particular function (or set of functions) is being called from several standalone scripts, then you can keep that function as a function in a separate file and it will be different Create the source in the script where it is used.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -