This lesson will be the students' first exposure to programming in the IDE (Integrated Development Environment). The IDE is a platform program that many programmers use to write their own projects. There are many IDEs for today's programmers. Some common IDEs include but not limited to: NotePad++, Eclipse, Netbeans, etc. All IDEs have special function to "compile" the program written in its environment and "run" the program. In addition to this critical function, many IDEs have supportive functions to point out some simple mistakes that programmers make. Some IDEs may include the function of an "auto-complete" that helps the programmers to write many lines of code easily and faster.
In a way, all IDEs work like a word processor program. Just like a word processor program - such as MS Word or Apple's Pages - helps the writer with spell and grammar checks for the English language, IDEs provide programmers with checks for the particular programming language they are using at the time.
There are two IDEs that students can use with Quorum: the online IDE and an offline IDE. There are subtle differences in using online IDE in the Quorum website and using the offline IDE, which is called Sodbeans.
The advantage of using "Sodbeans" is that it provides students with the rich programming experience of professional programmers with useful functions such as Auto-Complete, Tabulation of a code block, Debugging, etc. The extra work when the students use this method is that the students have to download the installation file from the Quorum website and install the IDE on their computers. The students will need to learn how to use it first as well.
On the other hand, the advantage of using an online IDE on the Quorum website is that it provides students with the ability to compile and run simple code without the installation process, and it also eliminates any concerns with their computer's capacity to use the IDE. As such, we recommend using the online IDE for all CSP lessons. If you would instead prefer the offline IDE, see the "Download" tab at the top of this page and follow the steps for installing Sodbeans.
Students will be able to:
The main purpose of this lesson is to start students on their programming journey in such a way that the focus is more on problem-solving rather than learning the syntax. Like the previous lessons about algorithms, by stripping down the available commands to only a few forces the students to think about the most efficient way to solve the problem and come up with creative ways of doing it.
A reason to learn this way is because at its core, a computer can really only do a few simple things: load a number from memory, store a number in memory, add two numbers together, etc. Everything the computer can do is the result of combining these simple instructions to do more and more sophisticated things.
Big picture: when programming at any level of expertise, we are always limited by the constraints of the programming language that we choose to use. Whether the language gives us thousands of commands and libraries with which to control various things or only a few, we always have to use those as building blocks to get the computer to do what we want. In this lesson, we simplify things dramatically for students by only providing 4 turtle drawing commands (namely MoveForward(), TurnLeft(), PenUp() and PenDown()) to produce simple line drawings. In fact, the problems can be solved using only move MoveForward() and TurnLeft()!
In this Quorum Computer Science Principles curriculum page, we have created the "Turtle Programming" to be accessible for the users who does not have a benefit of accessing the computer screen visually.
The students have been preparing to learn how to program by doing some activities using the "Human Machine Language" with cards. Today the students will start programming for "real."
Ask the students to think back to the algorithms activities, what do they anticipate will be the same about those activities vs. the "real" thing? Some topics to guide the discussion include:
The students are about to start a unit on computer programming, in which they will write instructions for a computer to execute. Computers are machines. So if they invent an instruction or command for a computer to execute, then it should be unambiguous how the computer will interpret or attempt to execute that instruction; so at the very least, as a group, we can expect that the machine's behavior is repeatable, so that the students can run some tests until they understand what the computer is doing and why. Remind them that the challenge - and fun - of programming is to understand how to use and combine those machine instructions to make the computer do what they want or to solve a problem.
In this course, and in computer science in general, all of the complexity we see on a computer is actually just the composition (the combining and recombining) of a few simple elements. To learn about programming, they are going to solve problems with only a few primitive commands. They will learn how they can build up very complex computer programs from only a few simple computer commands.
For the activities in this lesson, you will be using the Quorum Turtle Module, where you can control how a turtle moves by giving the turtle the following 4 commands:
The template of the Quorum Turtle Module is as follows:
You can click on Run Program to see what happens. There are three places that you need to be aware of.
Ask the students to run the Quorum Turtle Module program, their screen will show 11 rows by 11 columns of blue dots. There is a main character "the Turtle" on one of the intersection of the grids (there is an image below that allows the students to match up the intersection of the grids with the name of the position that the turtle is in, where the intersections are signified by dots).
The grid that the turtle walks on is shown below with the location of each dot signified by (...,...) with the name of each dot.
Description of the Image
By default, the turtle starts at (0, 0), which is the dot named a0
Try to change the coordinate that the turtle starts at by changing the values inside the SetStartingCoordinates action to (1, 0) for example.
Let's try the MoveForward() command by running the below program. Notice that the turtle will move forward one grid and the turtle will leave a trail behind. Also notice that the MoveForward() command is given to the turtle by inserting MoveForward inside the action TurtleCommands.
Now, if you have the PenUp() command before you ask the turtle to MoveForward(), you will notice that the turtle will move without leaving a trail behind. Think about where you can insert this command and try it in the IDE below.
If you issued the PenDown() command to the turtle after you have issued the PenUp() command to the turtle already, the turtle will start to leave a trail again when it moves.
Think about where you can add the PenDown() and PenUp() commands to the code below for the turtle to draw a dashed line.
After you have successfully drawn the dashed line, you can check the path that the turtle has taken by adding a OutputLines() command inside the TurtleCommands section.
Finally, the TurnLeft() command will allow the turtle to turn left from the turtle's perspective.
Start the turtle on the dot named a1, then try to draw a 1 x 1 square to the front and left of the turtle as efficiently as possible. The program should stop with turtle in its original position, facing its original direction.
The most efficient way to draw this square makes the turtle go around in a counter-clockwise manner. Therefore the lines shown in the output box should say: "New lines begin: (1, 0) to (1, 1) to (0, 1) to (0, 0) to (1, 0). End of lines."
Start the turtle at the dot named a2. This time, draw a 1 x 1 square to the front and right of the turtle as efficiently as possible. Notice that there is no command to turn right! The program should stop with turtle in its original position, facing its original direction.
The students will need to figure out how to draw this by only turning left and moving forward.
The most efficient way to draw this square makes the turtle go around in a clockwise manner. Therefore the line drawn in the output box should say: "New lines begin: (2, 0) to (2, 1) to (3, 1) to (3, 0) to (2, 0). End of lines."
Start the turtle at the dot named a0. Draw a 3x3 grid to the front and right of the turtle as efficiently as possible. The turtle should end at its original location, facing its original direction.
There are several correct solutions for this challenge, though some solutions are more efficient than others. This is the very nature of computer programming. Since they started the "turtle" at dot A0, the most common solution would draw the following lines (though not necessarily in the order shown below; the order would depend on the solution):
Consider listing the things that students came up with and posting them somewhere that can be read by the class. These can be used to motivate portions of the next and future lessons.
Think of an example outside of computer science in which you have heard the term "efficiency" and compare it to the ways we talked about efficiency in programming. In what ways is the meaning of "efficiency" the same? In what ways is it different?
Today we solved a series of problems with a limited set of commands (only 4).
Give at least one reason why it's useful to learn how to solve and program solutions with a limited set of commands.
In this lesson, you wrote code to make the turtle draw squares. Describe how the code for drawing a rectangle would be different than drawing a square.
Ask the students to summarize their experience with this first IDE lesson by answering the following questions.
Ask students to propose ways they could prove that their solution to the 3x3 grid problem is the most efficient. Note that an actual proof is very challenging.