Thursday 17 April 2014

Procedures and Functions

Procedures and Functions 

Procedures and Functions – GCSE Computer Science Revision. We talked about how you use a sequence of events to achieve a task. Remember that pepperoni pizza, and how you need to follow each part of the procedure in sequence otherwise you end up with no pizza?
If you ask your brother Sam to order pizza while you finish fixing your bike, you don’t say “ring the pizza place, choose a pizza, pay them and they will deliver a pizza that we will eat.” You just say “Sam! Let’s get pizza!” Sam knows what needs to be done. He’s on the case and he orders pizza without having to think through what he needs to do. He’s followed a procedure that we’ll call “ordering pizza”, and that title is a short label for a set of actions.
Now let’s have a look at functions. Imagine you wanted to know how many pizza variations they had at the pizza place. You could go in, make a list of all the choices and add them up to get a number, or value, and you would rejoice, because not only would you have discovered every single combination of toppings they offered, you would have performed a function! Happy days!
You could use a function in thousands of ways. For instance, you might want to know how many students graduated last year, or you might want to find out how many students over the last five years found jobs within three months of graduation. Then you might want to use those figures, or values, to find out what percentage of graduates found work within the local area, moved further away, or moved abroad.
Then there are built-in functions. In its simplest form a built-in function could be something like, pressing H on the keyboard and seeing H appear on the monitor screen. These are assigned functions that are particular to a programming language that has its own grammar rules. PHP, for instance, has over 700 of them. Why are they useful? If the function you performed when you went into the pizza shop was a built-in function that included access to an online menu, you wouldn’t have to write the code. You’d just have to tell the programme to carry out that function and it would trot off and bring back the number you need.

No comments:

Post a Comment

Wildern Pupils if you log onto your school email account you can leave a comment via that ID.