The first chapter is divided into three parts:
- What is a script and how do I create one?
- How do computers fit in with the world around them?
- How do I write a script for a web page?
A script is a Series of Instructions
Scripts can be compared to recipes, hand books and manuals.
For example, a cook can create a dish by following the instructions in a recipe. For new cooks, there is a lot of terminology, and the same happens for new programmers.
Employees get handbooks that contain procedures to follow in certain situations. However, they only have to follow certain steps in certain situations. Similarly, in a complex script, the browser might use only a small portion of code.
Mechanics use repair manuals to service cars they are not familiar with. Manuals contain a series of tests to check if the key functions of the car are working. This way a mechanic can pass tests and proceed further with the repairs. Similarly, the browser can perform only set of steps.
Writing a Script
To write a script, you need to state your goal and the tasks that need to be completed in order to achieve it.
When learning something new, it’s a good idea to break it down into smaller tasks and learn one thing at the time.
Computer cannot perform like humans, it needs to follow instructions every time it performs the task. For a computer every time is a first time.
- Define the Goal. First, you define a task you want to achieve.
- Design the Script. Split the goal out into a series of tasks.
*A good tip is to spend time designing your script before you start writing it. *
Here is an example of tasks of a hotel cleaner:
- Remove used bedding
- Wipe all surfaces
- Vacuum floors
- Fit new bedding
- Remove used towels and soaps
- Clean toilet, bath, sink, surfaces
- Place new towels and soaps
- Wipe bathroom floor
Each individual task may be broken down into a sequence of steps. The steps then can be translated into individual lines of code.
Just like learning any new language, you need to get to grips with the:
- Vocabulary: The words that computers understand
- Syntax: How you put those words together to create instructions computers can follow
*A programmatic approach to problem-solving. *
We need to learn to “think” like a computer, because they solve tasks in different ways than you or I might approach them.
That's what I have for now. I will try to continue with the book today! I hope it helps!