External Resources and Further Reading
Beginner Resources
-
What is Object-Oriented Programming? Video by
Kodable
-
Take a look around the room you're in right now.
What do you see?
Whatever is closest to you,
Try picking it up.
Did anything else in the room move
When you did that?
Unless you have mind control,
Probably not.
This is because objects around you
Can be changed
Without affecting any other objects.
Here's another example.
Let's say you decide to take your family's car
And paint it rainbow.
Would all the other cars in the world
Turn rainbow too?
No way!
Not even your neighbor's car
That looked exactly the same as yours.
But why not?
You can lift your pencil or paint a car
Without affecting anything else
Because the world is made up of
Individual objects!
There is a type of coding language
That mirrors how the world works.
It is called "Object-Oriented Programming,"
or "OOP."
In OOP, a programmer organizes code
Into self-contained objects,
Similar to the objects that are all around you.
So, why is it useful for code to be object-oriented?
We've talked about code before as just
A simple sequence of instructions,
And a lot of programs are built like this.
But what if you want to write a program
For something really big and complex,
Like a game?
Game code can be a few thousand,
To millions of lines of code long.
Without any clear organization,
Your list of instructions would end up
All jumbled, like a plate of spaghetti.
With so many intertwined noodles,
It would be nearly impossible to pull one out
Without disrupting the others.
In OOP,
We can organize code in such a way
That it becomes easier to maintain and change.
Almost everything you see in a game program
Has its own stuff, like data and actions,
That are totally separate from
The other things in the program.
But then they work together to make the game complete.
This is like pizza toppings.
If we structure code as objects,
Then we can change one part
Without messing up anything else.
So, you can pick off a pepperoni slice
Without it affecting the other toppings.
Both types of code are valid (and delicious!)
But will be useful for different projects.
We've been talking all about objects,
But what exactly are they in code?
Well, we actually have to answer this question first:
What is a class?
No, this class is not like the one you have at school.
In programming,
A class is a definition, or blueprint,
From which individual objects are created.
Think about a blueprint for a car.
The blueprint will tell you what a car has:
A body, wheels, engine;
And what a car does,
Like drive, brake, and turn.
But the blueprint itself is not a car, right?
It's just the definition of one.
Take the class blueprint and use it to build a car.
Now, you have an object.
You can use the blueprint to make many more objects.
Each one will look and behave the same.
The cool part is that once the objects are created,
You can modify each one without changing the rest,
Which is why you can paint your car
Without changing your neighbor's.
In other words, an object is just
The actual representation of a class.
So what does all of this mean for Kodable?
Well, most of the things you see in Bug World,
Like the towers, slimes, and fur babies,
Are all individual objects
That can be controlled separately.
At the start of any Bug World level,
You will determine the objects
That you will use to defeat the slimes.
As you play,
Collect the fur babies to gather points,
And then use the points to create new objects.
Notice the blueprint for the object's class
Shows up after the object is placed.
Similar to objects in the physical world,
These objects in the game can be modified
Without affecting any other objects.
Now it's your turn!
Log into Kodable, open Bug World,
And start creating and modifying objects
To defeat the slimes.
Good luck!
- Object Oriented Programming article by Software Programming For Kids
- This is a text article in natural language that introduces concepts of object-oriented programming. However, it is Python-specific. The site does include tutorials in Python, though. The important thing is that the syntax won't necessarily be relevant across languages.
- W3Schools Java Tutorial Section on Object Oriented Programming
- I love the approach W3Schools has to their tutorials, using minimal text and lots of hands-on examples. Again, this is language-specific; however, Java is likely the first object-oriented language many students will encounter in school.
Intermediate Resources
- MDN's Object-Oriented Programming article
- This may be helpful for an intermediate programmer who may be familiar with one programming language already. The examples are all given in pseudocode, which is very helpful for a language-nonspecific approach.
Advanced Resources
- Object-Oriented Programming in C#
- This article describes the four main concepts of object-oriented programming in the context of the C# programming language, a high-level language based on C, developed by Microsoft, and used with the Unity game development engine. The article assumes the reader already has a base understanding of C# syntax, objects, and methods.