1 of 14

Coding - Practical Tools

2 of 14

What is an IDE:

In any computer Coding language, an IDE is the Integrated Development Environment, which is a software application that helps programmers develop code. The “Sandbox” found on the CodeHS website, the many “Studios” found on the Code.org website, the Arduino app on the computers (or online), MakeCode Arcade, MakeCode for Micro:bit, and Scratch Coding are all examples of IDEs.

Some features of IDEs include:

  • Helping the coder find and correct syntax errors
  • Suggesting or providing code commands or code blocks
  • Running simulations to de-bug

3 of 14

What are “Docs” and an API?

In any computer Coding language, the creators of the language create extensive files called “Documentation” or “Docs” that provide coders with information about that coding language. An API is an Application Programming Interface, it is usually part of the “Docs” or documentation that allows coders, novice or experienced, to investigate each command or codeblock and get an explanation and even an example of how that command or block is used in a project for that coding language.

Some features of Docs and APIs include:

  • Breaks down the code into sections
  • Helps the coder understand the syntax, logical structures, and proper sequence of commands

Link to Arcade API - “Docs”. Links to CodeHS PythonTurtle & Python3 Docs Link to Scratch Docs

4 of 14

Important Coding Concepts

Regardless of the Coding Language

5 of 14

Pro and Experienced Coders Write Elegant, Efficient code

This means:

Coders use the fewest number of lines of code to accomplish a task

Instead of typing “forward 10” 100 times in a row, they might write “forward 10, repeat 100 times” (or they might write “forward 1000”. Because in coding, there’s almost always more than a couple ways to do stuff!)

Coders “comment” or “annotate” their code to let others know what their code does, or “comment out” a line of actual code so they can troubleshoot without deleting it.

# This code makes a square or // This code makes a square

Coders test their code often to discover and fix errors. They don’t wait until it is all written and THEN test it.

6 of 14

Pro and Experienced Coders Write Elegant, Efficient code (continued…)

This also means:

Coders look for patterns and code sequences that are repeated often - because they might be able to use specific coding tools to eliminate redundancies (repetitions)

Coders don’t “reinvent the wheel” - they use (borrow) code sequences from others when it is appropriate

Coders work with other coders to share and get ideas, troubleshoot problems, and brainstorm to find solutions

Coders use the Design Thinking Process to guide them while they invent and create

7 of 14

Once you find a pattern, you can use Loops!

Example:

To make a square drawing I move the sprite forward, turn right 90 degrees, then forward, turn right 90 degrees then forward, turn right 90 degrees then forward, turn right 90 degrees. That is 8 lines of code (4 forwards, 4 turns) I could use 3 lines of code: move, turn, repeat 4 times.

Example:

To make an automatic door open when someone approaches, my code needs to check/ask: “Is there anyone in front of the sensor?” Yes? Then open the door! NO? Then stay closed. Now, how often does it need to check? Just once? I could put an infinite number of lines of code that ask, but it’s way more efficient to put the question code in an infinite loop (hint: forever)

I can ask multiple questions - is someone in front AND is the door already open?...

8 of 14

Once you find some code that you use often, but at different times in the code, you can use “FUNCTIONS” to store the code and then get it every time you need it.

Example:

I could create a “Function” out of my 3 lines of code to make a square (move, turn, repeat 4 times). Then I could name the function “Make a Square”. It would be its own separate code that just hangs out waiting to be “called” by the main code.

I could create a function to make my character in my game do a happy dance each time the player scores.

I could create a function to make my rover back up several inches, beep, flash the red light, turn right 25 degrees every time it senses an obstacle in front of it.

9 of 14

Sometimes, we have code that uses number, letter or word values, and those values might change at different times while code is running. Coders use “VARIABLES” to keep track of these values.

Example: Keeping score

The score starts at 0, but the player gets a point. We have to create a “space” for the score to be saved. The space is a variable. We name the variable “Score”. At the start of the code, we set the variable “score” to a value of zero. �“Score = 0”. When the player gets a point, the code changes the value “Score = 1” and so on.

Example: User/Player Input

The code asks the user/player how many sides they want their polygon to have, and the user/player enters 3. The coder creates a variable called “Sides”. When the user/player enters the #3, the code changes the variable to: “Sides = 3”

10 of 14

And finally, Coders have to tell the code WHEN to begin

Whether the section of code is on a computer, a device or a robot… it still needs to know when to begin.

These are called “EVENTS” and are often based on whether a condition exists. (so it is asking a question… aka CONDITIONAL) Examples:

  • When electricity begins flowing? (turn it on)
  • When a condition is present (or a question is answered):
    • Is it close or far?, Is it bright or dark? Is it blocked or clear? Is it loud or soft?
    • Is the value < (less than) or > (greater than) or = (equal to) a specific value?
    • Is it a specific color? A specific level of sound or light? A specific distance away?

These lines or blocks of code may start with:

If…Then… If…Then…Else… While…Do… When…Do…

11 of 14

Click HERE to view & run the code.

12 of 14

Click HERE to view & run the code.

13 of 14

14 of 14

User Input - Makecode Arcade, Scratch, CodeHS Python or if you use another online Python editor/compiler IDE:

Process:

Ask the user for input. Either will be a numeric value (number) or a text value (“string”)

User input is then stored/saved for later use - generally saved to a variable that you have created.

User input is then used by other code. It might be compared, or it might be repeated. For example: if you ask the users name, then you might have the game use their name to talk to them during the game. What would be a good variable name for this type of data collected?

Example 2: You might have asked a quiz question so then you will need to compare it to the correct answer to see if the user got it correct.