How to Teach Computer Programming Effectively: The Importance of Code Organization

How to Teach Computer Programming Effectively: The Importance of Code Organization

  Having organized, concise code is essential for any programming language; however, most beginners do not realize this when they are learning and quickly fall into bad habits that are hard to break. CastleRock, Roboloco’s coding platform, will teach students to be better coders from the start. CastleRock teaches students three main ways to help organize code: pseudocode, commenting out lines, and blocking code into sections, in this case, three steps.


  Having organized code is like having an organized library. Depending on the size of said library, it could be completely unorganized, but you could still stumble upon the book you’re searching for after a few hours (you cloud still achieve your end result, but you might reach it in a convoluted, inefficient way). However, it is much easier to have neat sections such as fiction, non-fiction, children’s, journals, and DVD’s, as well as have every one of those sections follow the Dewey decimal system. That way, any book can be found easily, and your library will be successful; no one will get lost forever searching for a book that is not there. The same goes for code; even though sometimes you can reach the end result in wacky ways, the more organized the code, the better.

   One topic students might not think about before starting to learn coding is that you must directly tell a computer everything you want it to know. While computers are “smart” and can perform many tasks, all variables must be defined and code must be typed in a special order so the computer is able to recognize what you want it to achieve and follow the required steps. While you can ask another human, “please make me a bowl of cereal” and the task will be fulfilled correctly, when coding you must type the code to first enter the kitchen, then get a bowl, then look in the fridge to find milk, etc. This is when learning pseudocode might come in handy. Pseudocode is writing out, in plain English, the steps and information you will need to code in order for the computer to understand the end goal and run the program. An example of pseudocode to get a LED to light up would be, “include the Roboloco.h library, name RoboCore, name LED, attach LED, handle the event for the LED to turn on when the RoboCore is launched.” If pseudocode is written properly, writing the actual code for your robot will be a breeze, and the debugging process will be much quicker.


How+to+Teach+Computer+Programming+Effectively-+The+Importance+of+Code+Organization (1).jpg

  CastleRock also utilizes commented out lines to help organize code. Lines of code can be “commented out” by typing a /* at the beginning of a line, and a */ at the end of a line. This turns the text a light grey color in CastleRock, and means that when compiled, the computer will not read these lines of code. This can prove useful if you need to block out sections of code and give them titles, and CastleRock automatically does this for you with the Steps 1, 2, and 3 sections.

How+to+Teach+Computer+Programming+Effectively-+The+Importance+of+Code+Organization (2).jpg

  In any of CastleRock’s guided challenges, the coding panel will show Steps 1, 2, and 3 all commented out. Different information the computer needs to know to be able to run the code gets put in different steps.  Step 1 is used to name the parts you will be using. The RoboCore is always named here, as well as any sensors you will be using. Code written under Step 2 attaches sensors to ports on the RobolocoRoboCore. Step 3 handles events you want your robot to perform, like having a servo move. If all of these steps are used correctly, your code will be clear, and you will not forget any critical information when programming your robot.

     In addition to teaching students how to organize code properly, CastleRock is similar to C++, a common programming language. C++ was used to code Amazon, Paypal, and even Google Chrome. While it could be difficult to learn C++ on your own, learning CastleRock’s programming language will not only teach organization skills, but also give students an introduction to one of the most common programming languages at the moment.

     Organizing your code will give you a head up in many departments. First off, having organized code will be more pleasing to the eye. Most likely, you will not be the only one looking at your code. Teammates, teachers, bosses, or collaborators will need to view your code, and if it is organized, they will be able to understand it better. This can also be helpful when you need to revisit code you wrote a long time ago. Secondly, having organized code will make debugging an easier process. If you are able to clearly see all of your code written out, it is easy to check for simple mistakes, such as not ending a line with a semicolon, and then move on to comment out blocks of code until out until you find the problem. The CastleRock programming platform is sure to teach you how to be a better coder from the start. Start learning your first programming language today!

Derek Capo