02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

OOP Classes

We learned so much in the last few videos we now are working in a world that has objects. our next problem is that until now when we wanted to create a cat we had to create every single operation of a cat while in the real world we would want to create a prototype to a cat and then mass produces it. This is done through our next topic - creating a template for cats we need to introduce a new concept a way to create blue prints for objects - in OOP terms that is called a Class. in this video we explore the need and see how its used in action (in a visual way).

Video Transcript

00:00Now we have a new problem now, let's think what could be as our application is developing so far
00:05We have only one cat that's Jerry the cat but at some point we're gonna want to be able to duplicate cats
00:10We're gonna want to create more than one cat Jerry. Not only that we want to create different cats with different properties
00:16and that leads us to our next challenge as as
00:21We're as we're developing our object oriented understanding to why all these different terms and all these different types of things exist
00:28So our next issue is okay. Everything is good so far. But what if we want to create now another cat?
00:34How can we do that? Until now everything we did was explicitly connected to Jerry
00:40And if we correlate this into the into programming world, basically we've been putting everything inside of an object
00:47directly on the stage
00:48Directly in our code so we had no way to actually in an easy way
00:52Just duplicate that function and create another another cat that has a few different different variations
00:59So our next step is from creating objects directly
01:02We have to figure out a way to actually create blueprints for these
01:07Objects so we can then create blueprints and just stamp and create as many as we wanted them and that leads us for that
01:12Our next topic that's an object-oriented program
01:16for us to create a template for our cats we need to introduce a new concept a
01:20template aka a class a class is a blueprint to create new objects and that's really all it is so whenever you see the
01:27Word class all it really is or whatever you're working with a class. You might have been working with two classes, but haven't really
01:34understood it's real
01:36It's real purpose or maybe you did and then this this this part is not gonna be as interesting as hopefully the next one
01:42But the classes role is main role. It's really just to create a blueprint and define new objects and
01:48The way we do that is if we go back to our application is very simple
01:53so instead of creating Jerry the cat we're gonna create the cat class and
01:56When we have our cat class that holds has all these
01:59Properties and functions and all these different things then whenever we're ready
02:04We could create a new whatever the name of that class is and then open and close a curly brace
02:09at least that's how it's done in action script 3 and
02:13If we look at it just on the side
02:14Which is if our class was called cat we would just create a new cat and that would basically
02:18Duplicate that class that we created now
02:21We're not digging into right now into actual the construction of the class unless you guys want us to just take a jump in and
02:26Look how classes are built soon
02:29But idea really is very simple you create a class that class is a blueprint and then whenever you want to create a new
02:35Object out of it whenever you want to create a new Jerry a new whatever it is
02:38Then you just define a new and put the name of the class and then a new
02:42duplication of that specific type of object is then created and
02:46It's derived out of all these functions that are inside of that class

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!