3.1 Principle 1: Tweaking code
Code is just text. It is written in a strange language and grammar – its syntax – but it is still just text. The language and structure are strange because they need to be interpreted by a computer and, despite what you hear in the media, computers are very stupid and can only do what they are told.
As well as the code syntax, there are certain technical terms that you will come across, such as parameters and variables, that have specific meanings when talking about code. Unfortunately, this is unavoidable because there are technical concepts associated with programming that are very distinctive and don’t have common language alternatives. We will try to avoid jargon as much as possible and explain terms as you go through these principles, but you might find that there are some terms that are not explained in enough detail. A good place to start is by searching online, where you’ll find a wide range of tutorials. If you enrol as a student at the OU, you’ll also have access to tutors and subject specialists who can provide additional support.
Initially, you may find it daunting to read a piece of code, but just like any language, the more you look at it and the more you use it, the more familiar it will become. And, just like any other text, code can be edited. The kind of edits you will have to make are tweaks – small changes to the code that have big impacts on what is created.
As you work through the coding activities, you will be encouraged to tweak the text of code inside the p5.js editor frames. Try not to be nervous about doing this; you are in a safe environment, which has been designed to allow you to experiment with what is possible with code. You cannot break your computer, or your network, or the internet by editing the code in these exercises! The worst you can do is stop the program from running, and that can be easily fixed by undoing the changes you made or reverting to the provided code.
The following program is a p5.js editor frame. It doesn’t do anything right now. You will see many of these as you go through this course, but they will all be filled with example code that gets you started. The Play and Stop buttons make the code restart or stop. The canvas is the space to the right of the code that appears when you press Play.
You can undo any changes you make by using the Undo and Revert buttons that appear after a change has been made.
The words ‘programming’ and ‘coding’, and ‘program’ and ‘code’ are used interchangeably throughout this project. Yet an important distinction should be made between a program, which is fully functional and standalone, and a codesnippet, which is a chunk of code that does a small task as part of a larger program.
One of the main tasks you will be doing when tweaking code is moving little snippets of code around, sometimes to repeat a shape, or to take a codesnippet that you made previously and insert it into another program. Using codesnippets is a modular way of working with code, and it is a very important practical and conceptual skill to learn.
To help you with this, you need to create a codesnippet text file on your computer, where you will save any codesnippets that you are working with.
Don’t be precious about this file; it’s just a working place to store ideas, a bit like a sketchbook full of chunks of code. You will use this file for storing, copying, and pasting snippets into different programs.
Activity 1 Make a codesnippet text file
Follow the instructions in the following video to create a codesnippet text file on your computer where you will store little chunks of code.

