Do you understand classes, let's understand object oriented programming now, depending on your level
of knowledge and if you worked with modern JavaScript, that maybe also some other programming languages,
you might be aware of what Claus's hardware for and what OPIS object oriented programming is all about.
So Darfor, you can also skipped his lecture to jump right ahead to the part where we write code.
Otherwise, definitely stick with me because it is important to understand this.
The idea behind object oriented programming and classes will be important for that, as you will see,
is that you work with real life entities in your code.
You could say so.
Did you work with things in your code with objects that resemble real life objects as far as possible,
at least to make it easier for you as a developer to reason about your code?
For example, we might be building an online shop and there we might have a product list.
We might want to work with a product list, object data for which has everything we need to manage a
product list.
A method to add products to the lead products.
The list itself.
So for example, this might be an object that is responsible for rendering a list of products and for
managing it, which were fetched from a service, from a database.
So this product holds all the rendering and fetching and management logic.
Now that's a product list in our program into Web site we're building.
We might also need to work with the individual product, though, so we might all the one that object
or multiple objects, one for each product that is responsible for managing this single product.
It might hold and render the details about that product, maybe allow us to add it to a cart.
Things like debt.
So when we want to draw a user interface to the screen, we want to manage that through JavaScript and
deafer for typescript.
Then we could implement it with a product list and a product object which hold the logic for managing
the underlying data, but all for rendering the content on the screen.
And of course, Stanford, these two objects would kind of be related.
We might also have a shopping cart object on our screen, which is responsible for rendering and managing
the shopping cart.
It's of course, also connected to the product and therefore it holds all the logic we need to render
our shopping cart, placing orders and communicating with the server and so on.
So that would be one way of how we could think about the applications we're building, how we could
split it into logical pieces.
That makes sense to us as humans and encode in typescript and JavaScript in most modern programming
languages.
Does this actively supported because we have objects which are more complex data structures that hold
properties and methods.
And of course we do have that in JavaScript as well.
But we might also have classes that help us with that.
Now, what's the idea behind classes and what are incenses?
Well, we've got these objects and when following does object oriented approach, we could consider
splitting our app or our application logic into such objects which manage parts of our logic.
Now, connected to the idea of using these objects, which of course do exist in JavaScript, we can
use objects.
There is the idea of having classes.
Objects are the concrete things we work with in our code.
The data structures we use to store data, to store methods to execute methods on classes are blueprints
for objects.
Classes allow us to define how objects should look like, which data they should hold.
Which methods they should have so that we can easily build objects based on these classes.
And we then called this instances off the classes.
So an object then is an instance of a class.
If it's based on such a class so that we can quickly replicate multiple objects with the same structure,
the same methods based on the same classes.
So classes help us define how objects should look like, which properties and methods to have and so
on.
So classes exist to speed up the creation of objects and it's simply an alternative to using the object.
Literal notation, you already know.
They simply make it easier.
Classes simply make it easier to create multiple objects, which generally have the same structure and
the same efforts, which might only defriended exact data details which are stored in there.
Let's say we have multiple persons we want to represent with objects.
While each person might have a name and a H, the values will differ.
The general structure is the same.
So that's the theory.
Let's see it in practice.