So welcome to the brand new section where we're going
to be taking a look at object oriented programming,
otherwise known as OOP.
OK,
this is where we're going to delve into some advanced aspects of programming.
But don't worry, I will be here to explain to you in the simplest manner possible.
So what exactly is oo
what you see in front of you is
basically a library, right? You've got all sorts of books, you've got books on
anthropology, archaeology, biology, chemistry, math, and so on.
Imagine you were the librarian, you were the person in charge of all these books.
Ideally, of course, you would need some sort of a system
to manage these books, right? You will need to know where to put the books.
You will need to know the
characteristics of each book, like you know, the title of the book,
the author of the book.
And also whether or not the books are available, maybe they've been buried,
stuff like that.
So
imagine that we created a class called book.
OK.
And just like I said,
this class can define several kinds of characteristics about each book,
like the title of the book the author, the genre,
the cover color.
But besides the physical attributes of the book,
we can also talk about the things that we can do with the book.
Maybe you can borrow the book
and if we can, how long can we borrow the book for?
Maybe we can even buy the book and so on.
Ok.
Think of all these attributes
under
the class book.
All right.
Now,
things like the title, the author, the genre,
things that physically describe the book, we can call them attributes,
right? We've talked about attributes already in this course.
But then methods,
methods will describe what it is that we can actually do with each
book.
Can you borrow it, can you buy it?
So basically the book class
will define both the attributes and the methods.
So
in other words,
the book class is like a general description of what a book
might look like and what we can actually do with the book,
but we're not referring to a specific book just yet.
All right.
Now
each individual book in the library
is what we refer to as an object of the book class.
So once again,
the book class will give us a general description
of the attributes and methods of each book.
While the books themselves, the individual books,
they will be called objects of the book class.
So
the object attributes
of book A for example,
could be the title is Python programming.
The author could be Jack and then the color could be blue, right?
And then let's take a look at book B, the title could be cyber 101.
The author is Alice and the color is red.
These are individual attributes of each book
and the attributes have their own values.
The value of the attribute color for book A is blue as an example, right? And so on.
So the methods
we can also for example, say book A has a method called borrow
whereby
once the book has been borrowed,
the library will have to update the records to indicate
that the book is no longer available to be borrowed.
And likewise imagine book B
had been borrowed in the past, but now it's been returned,
we can then mock book B as available again.
So these are methods, these are attributes.
So
to give you a quick recap,
the class is kind of like the general description of the book
where the attributes and methods are defined.
The object is an instance, basically a specific book in a library,
a specific object on the class, the book class
attributes will be physical description of each book.
While methods otherwise known as actions
are well, essentially the actions that can be performed on each
book.
So
join me in the next video where we're gonna start taking a look at some examples.