Learning to Program: Getting Started by Scott Allen
Usually Scott Allen teaches intermediate to advanced courses, but here he shows that he can teach to any audience by presenting this course on getting started with programming. You do not need to have any experience in programming, either in JavaScript or another programming language.
This course is also the first of a three part series on learning to program. If you are not necessarily focused on JavaScript and just want to learn programming in general, then after you watch this course you can deviate from this learning path and instead watch Part 2 which teaches abstractions in the Python language. The final course in the learning to program series has good advice on ways to keep learning and improving as a software developer.
There is some content here that may benefit the non-beginner as well. Many professional developers only use JavaScript in the web browser and have not used Node JS yet. Scott begins by teaching how to install Node JS and uses the REPL for the first examples.
The best way to learn is to follow along with Scott, entering the code as he demonstrates each example.
Variables and Types
In the second module, Scott teaches text editors and code files, starting with Notepad and programming “pizza” and “fish and chips”, and moving on to Notepad++. The var keyword and semicolons are introduced in the “syntax rules” clip. Then in the “when to panic” clip we learn how to create, read and diagnose some common error messages.
Then we see the first potentially useful program: taking the number of people in a party and calculating their bill for their piece of a pizza.
The following module covers variable declarations and types. Scott shows that a variable returns undefined if the type is not set, and creates an “x is not defined” error.
The type of keyword is explained. Most of JavaScript’s built in types are covered. This was the first time I have seen the types of console and console.log being output.
Scott explains the parseInt function for converting to numbers, and shows a writeGreeting function.
Functions
Scott writes a roll the dice game which outputs two random numbers between 1 and 6 (representing die values) and sums them together. This covers math functions such as rand and ceil, and the code is wrapped into our own function.
Scott explains that there is online JavaScript documentation to explain all the details of the language.
Then the example is enhanced to support different dieSize, for example if we can simulate seven sided die, or any other number of sides.
In the scope clip Scott explains that local variables can only be accessed inside a function, but global variables can be accessed from anywhere.
Branches and loops
Covers if statements, several operators including and (&&), or (||) and not (!), else blocks,
and then while loops and do while loops. Also, for loops and arrays.
Objects
After explaining what objects are and how to create them, Scott demonstrates splitting programs into multiple files, and using the exports and require keywords in Node.js to read data from other files.
Tests
The example used in this module is a grade book. Scott downloads nodeunit from NPM. I had not seen this unit testing framework before, based on the version covered in this course it seems quite basic but is enough to cover the most common scenarios.
Credit to Scott for covering Test Driven Development (TDD) in a beginners course. Often it is described as an “advanced” technique, but Scott shows that it is actually quite straightforward. In the second test we see a flawed test that is not doing what we first might think it is. Assigning a function to exports[“setUp”] which reinitializes the object that we are testing, is the fix for our unit tests.
Final
In this last module, the grade book is enhanced to assign letter grades (e.g an average score of 90-100 is an A). This is done using TDD again, although Scott challenges you to write the tests for grades B, C, D and F.
Next, Scott introduces Express JS, a very popular web framework for Node JS. This is easily installed by typing the following into the Node console window:
npm install express
Scott begins with a hello world message, which displays in the browser. Then he adds a command for running the grades program using user inputted scores. The example displays:
Your average is 91.25 grade A
Recommended speeds:
Children and adult beginners – 1.0x
Experienced amateurs – 1.5x
Pros new to JS – 2.0x
JS Pros – 2.0x and skip at least the first few modules