Thursday 26 May 2011

My IF / ELSE interpretation


An ‘IF/ELSE’ statement in computer coding is used like a road block, first it begins with an ‘IF’. Inside of the ‘IF’ statement will be a condition, and if it is true, then the computer will carry on in that direction. If it is false, then it can only move on to the ‘ELSE’ option. This means that if the first part wasn’t true, then everything else that follows will be completed by the ‘ELSE’ statement. You can have more than one ‘IF’ statement at a time, and any subsequent ‘IF’ statements are called ‘ELSE IF’. For example, Traffic lights; ‘IF’ you drive up and see a red light (the first condition) then you must stop. Or ‘ELSE IF’ you drive up and see an orange light (the second condition) then stop if you can. Anything ‘ELSE’ (green being the only option left) then continue driving. ‘IF/ELSE’ statements are used in coding the same way we use day to day rules.
The metaphor I chose for my model is that ‘IF/ELSE’ statements in coding relates to a buzzing wire game. The condition is, while the game is being played, ‘IF’ you do touch the long loop of wire the result is a buzzing sound and you must start again. If you don’t touch the wire (‘ELSE’) then you may carry on.

No comments:

Post a Comment