The Guide to Teaching Coding for Middle and High School

Teenager coding

Introduction

This guide provides a framework for teaching coding to middle and high school students. It is meant for people who want to introduce computer programming to students but who are relatively new to cit themselves. It contains a list of computer terms for reference.

What is coding?

Coding is the process of writing a computer program or application that solves a problem.  When it is taught in schools, learning to code is a way for educators to teach computational thinking.

Computational thinking is closely related to critical thinking and is a skill that figures high in the guidelines in the Next Generation Science Standards (NGSS). It is a way of thinking that is considered necessary for a lot of today’s jobs.

The steps in creating a computer program

Writing code is a type of creative process so, even though there steps, they are not something that needs to be done in a linear fashion from beginning to end. In fact, writing a computer program can take multiple iterations through each of the steps.. With that in mind, there are four phases:

Define the problem

In this step, the problem to be solved by the computer code is stated in plain language.

Develop the algorithm

In this phase, the problem is written as a step-by-step plan that shows the tasks that must be performed by the program. This plan is called an algorithm.

An algorithm can be written in standard conversational language or pseudocode. Pseudocode is a step closer to actual code but still does not contain any coding syntax.

An algorithm could be done as a flowchart, or it might be written in outline form. The finished algorithm should be written in a manner that is abstract.

Write the program

This involves translating the algorithm into computer code. This step uses a specific programming language, like Python, Java, or C++. If the program involves hardware, like microcontrollers and peripherals for the microcontroller, it may require extra code libraries to handle the device. This should all be thought out ahead of writing the code.

Execute the code

Running the code will show you how it behaves when it is run on a computer or other device. This is the stage where you can see how your code is interpreted, determine any changes, and try again.

 

Computer Terms

Abstraction

Abstraction in computing is an important part of writing an algorithm.  It is the process of removing anything that is connected to the real world to reduce the task to its key parts. This helps simplify tasks and allows algorithms to be written so they work for a range of values. For instance, part of the task may be to add 2 and 6. The abstract version would be to add two numbers.
Another example of an abstraction is sorting items in a list from least to greatest. Your particular application may be alphabetizing a list of names but the act of sorting could also refer to id numbers or grade level.

Algorithm

Algorithms are step-by-step plans that show the tasks that must be performed by the program.  An algorithm is written in informal language that will be translated into computer code. An algorithm could be done as a flowchart, or it might be written as pseudocode. In this step, the focus is on writing it in a manner that is understandable. This is the point in time where the physical aspects of the problem should be abstracted out of the description.  They are the first step in abstracting a problem so it can be used as a diagram for writing pseudocode.

Conditional Logic

Expressions that must be evaluated to either true or false to determine what the next process is. An example of a conditional statement is an IF/THEN/ELSE block.

Event Handler

A block of code that performs an action when a particular event occurs.

Event

An event is a trigger combined with an event handler. The trigger signals the code to perform the action of the event handler. An event trigger could be caused by a human, some physical event, or something that occurs in the code.

Loop

A loop is a method of cycling through a section of code a given number of times. The types of loops include ‘do while and ‘for.

Pseudocode

Pseudocode is one way to write the algorithm prior to coding. It is written in a combination of natural language and computer code.

Variable

A variable in computer science is a container that is used to store data needed by the code. Common elements stored in variables are numbers, a character or set of characters, lists, colors, or true/false.

Variables can be tricky to understand because each programming language has its own set of rules for how variables handle information. For instance, in Java, if one variable is assigned the value in another variable (e.g. var1 = var2), the data is not copied into a new variable. Instead, var1 is given the location of var2, so if you now alter var1, you will also alter var2. This is called a ‘shallow copy’ because it uses less computing power than a ‘deep copy’.