Splitting code to procedures or functions
Even so same functionality can be obtained by implementing same code several times within main body of a program, it is probably not the best design. It is a good idea to put repeatable code in standalone procedures and to call those procedures instead of executing same code again and again.
The difference between function and procedure, is that a function will return a value, but a procedure will not.
Example of a function is a sum of two numbers, example of a procedure - printing something on a screen.
Comments
Post a Comment