Hi and welcome to this new section where you'll learn about object-oriented
programming often referred to as OOP for short. Now if you have experience
with programming that's probably a familiar concept for you because OOP
is used in most of the languages, but I assume you don't know anything
about object-oriented programming so I'll explain the concept from the
beginning. Now there are various definitions of OOP out there and some
get very tricky, but I believe the best one to know is that object-oriented
programming is just a way to organize your code. That means Opie is not a must.
So you can simply use functions to build an application as we did here with our
bookstore application, and many programmers choose to not use
object-oriented programming to organize their code, they don't use the OOP way
to write their code in other words. However it is generally accepted that if
you have more than two functions which apply operations to the same object,
for instance a program that applies operations to a tkinter interface, so
you have this callback functions, and so you should organize these functions into
something called a class. Now because object-oriented programming is a complex
concept I didn't include that in the beginning of this course, so I wanted
that you first built some applications using functions which is more intuitive,
and then you move to object-oriented programming. So back to our graphical
user interface application. So the object here, I'm talking about objects and the object
here is the entire window with buttons and other widgets as well now we can put
all the attributes that define this object so this window such as
the title of the buttons, the label, and also the callback functions
attached to this object inside the class. So in our application we didn't use
classes, we used functions so this script here does not apply to object-oriented
programming, and putting this object inside a class means we are organizing
the code in a class which creates, an object so that's why we call it
object-oriented programming. And using classes to organize your code
is referred to as object-oriented programming, and what I'll do next is in
my backend script where I have the database operations I'll transform this script by
putting this inside a class and after that you can do the same for the frontend
interface so that you practice object-oriented programming. Now my
purpose here is not to train you how to write classes. I first want you to
understand classes, and many learning resources explain object-oriented
programming by saying something like we create a class that creates a dog object,
and the dogs can eat, and bark and so on. That's a good example to train
you to learn the syntax of a class, but hey what is a dog in in programming?
I mean you can scratch your head all day trying to come up with
a scenario where you have a dog as an object in your application, and then that
still a good example, but only if you have some years of experience in programming,
and you can quickly think of where and when to use classes based on such
examples. I assume you don't have these years of experience, so I'll use
real programming objects in this section to explain such a tricky concept as
object-oriented programming. So the best way to understand OOP is to first build
a program with a known object oriented programming approach, so using functions,
and once you know that program well, then you build that program again using
OOP, and then you automatically understand what OOP is by looking at how
things are different. So let me organize this code using classes now and later
we will build a simpler program from scratch where we create a bank
account object with Python, and we will apply functions to that object such as
withdraw, deposit, and so on. That's great, and yeah, that's about this
introduction, and let's move on to the next lecture and write some classes.