Do you remember the last time you used any bit of technology? It probably wasn't more than a minute ago. Coding, while a vital part of our world, remains unknown to a vast majority of the population. Technology runs rampant and the progress of technology has become our new norm. Something as simple as jumping up and down in a video game can be complicated to replicate in code. In this article, you'll learn about important coding concepts that show the complicated side of simple actions.
Message Passing
Message passing is when one object of your code sends code to another object of your code. This usually precipitates an action. To put it in simple terms, it's like when you swing a bat against a ball and the ball flies backwards. This is used in the outside world such as pressing keys on a device to type something up or motion-detected sensors triggering an alarm. Let's look at a real coding example in Scratch.
Message Passing Demonstration
In the Scratch project linked below, the cat moves according to the areas on the screen. When the up arrow is clicked, the cat faces up and moves in that direction.
The code shows that when the arrow is clicked, a message — Up — is broadcasted to all sprites (message passing in Scratch). When the cat receives the message, it looks in the up direction and moves 10 steps.
Variables
Variables are placeholders that can store information. They have a name, and in most programming languages, a data type. To put it another way, it's like the amount of money in your bank account. It's not at a set value. It is used in computing like the set password for a computer and the amount of storage space on your phone. Let's look at how it can be used in the programming language Java.
int number = 0;
String animal = "cat";
System.out.println(number);
System.out.println(animal);
number = number + 1;
animal = "dog";
System.out.println(number);
System.out.println(animal);The code starts off by declaring the variables, or in other words setting an initial value for new variables. The number variable is set to zero and the animal variable is set to cat. This is shown as the variables are then printed to the output. Then, the number variable is increased by 1 and the animal variable is set to dog. This is shown by the last two outputs.



