The x4 Principles of Coding

Let’s begin: Back to first principles

The x4 Principles of Coding are the basic skills needed to begin to code.  I give my students basic tasks that use these principles, firstly using Scratch.  At about year 9 I move my students onto new languages such as Sniff, Arduino (C++) and Python, but again I start by teaching these x4 principles:

  • Variables
  • Input/Output
  • Loops
  • Decisions

Explanation

  • Variables
    • “Enables a computer to remember things”
    • Variables are place-holders that can store a value that can be changed
    • eg. Used in maths: if x = 3 and y = x+2 what is the value of y? etc.
  • Input/Output
    • Telling a computer something
    • Enabling a computer to tell you something
  • Loops
    • Repeating instructions
    • There are two ways to repeat instructions:
      • WHILE loop
        • loop while a condition is true
        • eg. WHILE iAmHungry()=True LOOP eatPasta() END
      • FOR loop
        • loop a specified number of times
        • eg. FOR x = 1 to 5 LOOP
  • Decisions
    • IF <something is true> THEN <do action 1> ELSE <do action 2> END
    • eg. IF isIsRaining() THEN wearAHat() END IF

More examples can be found in Resources

scratch pong.fw    pong skills sheet thumb.fw

 Next: Teach “Sexy Code”