What are Classes?
Now that we built our first class its time to go back to the theory and talk about what we just did and why we did it. In this video we will attempt to answer the question 'what is a class?' that is asked on google 74,000 times a month.
Video Transcript
00:00We just built out a class, and it's our first class that we actually built from scratch
00:03And as we said that classes are blueprints and what does that mean when we say classes are blueprints?
00:09What we actually mean is that?
00:10They create the objects, right?
00:14Until now we just created objects from classes. We didn't really know we didn't really look over those classes
00:19We've seen our our you know our main class, but we didn't really dig too deep into it
00:25And in the world of object-oriented programming the whole concept behind is there's a lot of stuff that are
00:30Reusable and as things are reusable
00:33Why can't we just put them in some sort of blueprints just as much as you would have like some sort of a signature stamp?
00:38That would just you know stamp stamp signatures over and over
00:41What if there's some sort of behaviors that we could capture into into classes and then create objects that would store those?
00:48information so we could reuse them
00:50So in this scenario we wanted to create a timeout class because let's say we want to create a few different timeouts
00:56You know maybe we have like that one logic set that could then be you can be reused throughout our application or even better
01:02We might want to reuse this timeout class and other projects
01:06So you're creating a time that we're gonna create a simple timeout
01:09and we might want to use that timeout for other promotions you're doing on your site or
01:13Any any use that you would need a timer of some sort there is also one more thing
01:18That is it tends to be a bit confusing and we talked about it a little bit before but I tried to kind of like
01:23Slide it through until now. Is it the whole word object? What does that mean the whole word object?
01:29And the the from the basic and hopefully you're getting one of the two is that objects are basically the manifestation of a class
01:38So after a class after something goes through a class and create a new a new object a new array a new
01:45Now we're gonna create a new timeout when you create the new timeout. It's basically taking the information from the class
01:52From that blueprint and then trying to get into something tangible usable
01:56You could grab now use it and it's completely disconnected in that point from the class
02:00so if I'm creating a method inside over my class or I'm creating a
02:04Property or so forth and then I'm going to duplicate it and create like we created an object
02:08We could create three four objects and it's fine, right because every object stands on his own
02:14It's not that because there's an object class in the background that they automatically share between them the data
02:20They share behaviors because the blueprint told them these are the behaviors that you're going to have
02:25But after the object is created and it's in the world
02:27It has its own merits and it could do a few things on its own such as store information
02:32Which is the whole point of variables or do conversions and so on and so forth now
02:38With that said there's also the object class and we haven't touched inheritance too much
02:43We kind of started we started looking at it as we looked at charts for the visual objects, but end of the day
02:49The inheritance and we're going to look in deeper into inheritance when we actually practices it ourselves and we create an inheritance
02:56But until that point what is inheritance what we need to know about inheritance is that there are behaviors
03:02That we inherit from other classes
03:05So even if I didn't define anything inside of this class, it's gonna have behaviors
03:09Why because if I don't set a behavior automatically, there is a class that is called the object class
03:14It's an internal private, you know proprietary Adobe class
03:19And in that class, there's a few stuff a few basic a few basic things that are there, you know a few basic
03:26methods and properties and even
03:29Yeah methods and properties which are
03:31automatically going to be added into any class because doesn't matter what we do they will always inherit at some point from the
03:37Class even if we go there directly or it's the parent of the parent of the parent of the parent
03:41You know one of the ancestors one of the great great grandfathers of that class
03:44Would be the object class now in our scenario because we're not doing any extensions
03:49We're not telling it who his mama is or data wherever you want to call it
03:54then it's automatically it's mean it's
03:56Inheritance changes. So the thing just above it is the object and that's gonna happen automatically
