Understanding Objects in Coding – Explained for Kids

In coding, objects are like special containers that can hold both data and functions. Imagine a toy box where each toy has its own unique features and abilities. Similarly, objects in coding are created to represent specific things, like a car, a person, or even abstract concepts like a game character. These objects can have properties (such as color, size, or name) and actions (like moving, jumping, or making sounds). By using objects, you can organize the code more efficiently, making it easier to manage and understand.

Watch this CodeMonkey video to learn all about Objects in Computer Coding:

Read the transcript below:

Welcome to Objects and Friends! Let’s learn about objects.
Many programming languages are object-oriented, including Python, Java, and our very own CoffeeScript.

In CodeMonkey, objects are the characters on the screen, and because CoffeeScript is object-oriented, it means that you can use those objects in your code.

Let’s look at an example.

objects 1

Here’s a challenge that has several characters on the screen. You can tell which characters are objects by hovering your mouse on top of the character, and if a name pops up, it means it’s an object that you can use in your code.

So of course, the monkey got the turtle, both bananas, and all these bushes, but is the ruler an object? No, and Gordo isn’t one either, but all these other images are objects.

Now, let’s see how we would solve this challenge. So we want the monkey to get the banana in the stream and also this banana.

So the monkey will have to somehow get on the turtle, have the turtle move across the river, and then go and get this banana also. What we could do is we have the command “turn to,” and we could turn to any object. I mean, I could turn to one of these bushes, but I think I want to turn to the turtle.

So I will say “turn to,” and because this is an object-oriented program, I could just say “turtle,” and then I could step. Now I don’t need to mention the monkey in my code because since the monkey’s the main character of the challenge, it will automatically refer to the monkey.

But if we want the turtle to step, I’d have to mention the turtle. So right now, we’re gonna have the monkey step 10. Let’s run that. Okay, so now the monkey is on the turtle.

So next, we want the turtle to go in step, so because we want the turtle to step, I actually have to say “turtle step.” And let’s see how far it is. Okay, I think it’s 15. So it’s actually “turtle period step space 15.” Okay, let’s run that.

objects 2

Okay, we’re all lined up. I could have the monkey turn to the banana object, but they’re saying I also could just walk backwards, and that would be less code, so let’s do that.

Do you remember how to make the monkey walk backwards? Yeah, you use a negative number. Okay, let’s run one more time. Okay, we did it. Hopefully, that explains how different characters are objects and you can use them in your code. Now it’s your turn to use objects. Good luck.

Want to watch other Coding Basics Videos?

Visit the CodeMonkey YouTube channel.

ABOUT THE AUTHOR

Pam Rissmann is a middle school STEM teacher who teaches computer science, robotics, and product design. She has been teaching for 15 years, and in addition to teaching, she coaches her school’s competitive math club and STEM Girls club. Pam is a recipient of the Santa Clara County/Texas Instruments STEM teacher award and California League of Middle School Teacher of the Year for her school. Pam was awarded by Project Lead the Way the Outstanding Gateway Teacher award in 2019.

Try CodeMonkey at home or at school!

free trial

or

for your school / district

More to explore:

Table of Contents

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to CodeMonkey's blog

Stay Up To Date on The Latest NEWS
AND LEARN MORE ABOUT CODING FOR KIDS.