In this course, we will cover the basics of programming. Basically we will answer the following questions: What is script? How do computers understand our world, how do we communicate with computers?
What is a Script?
A Script is a series of instructions that a computer can follow to achieve a goal.
A browser may use different parts of the script depending on how the user interacts with the web page.
Scripts can run different sections of the coe in response to the situation around them.
Writing a script
To write a script, you need to first state your goal and then list the tasks that need to be completed in order to achieve it.
Start with the big picture of what you want to achieve, and break that down into smaller steps.
- Define the script
- First, you need to define the task you want to achieve. You can think of this as a puzzle for the computer to solve.
- Design the script
- To design a script you split the goal out into a series of tasks that are going to be involved in solving this puzzle. This can be represented using a flowchart.
- You can then write down individual steps that the computer needs to perform in order to complete each individual task (and any information it needs to perform the task), rather like writing a recipe that it can follow.
- Code each step
As tempting as it can be to start coding straight away, it pays to spend time designing your script before you start writing it.
Computers Create models of the world using data
Here is a model of a hotel, along with some model trees, model people and model cars. To a human, it is clear what kind of real-world object each one represents.
Objects and Properties
In computer programming, each physical thing in the world can be represented as an object. There are two different types of objects here: a hotel and a car.
Programmers might say that there is one instance of the hotel object, and two instances of the car object.
Each object can have its own:
Together they create a working model of that object.
Both of the cars share common characteristics. In fact, all cars have a make, a color, and engine size. You could even determine their current speed. Programmers call these characteristics the properties of an object.
Each property has a name and a value, and each of these name/value pairs tells you something about each individual instance of the object.
The most obvious property of this hotel is its name.
The value for that property is Quay. You can tell the number of rooms the hotel has by looking at the value next to the rooms property.