Object-Oriented
Programming (OOP) is basically how Python works. This organizes a program by
creating an object, because objects contain both data and functionality. The
main key idea of this programming type is using classes, which create a new type
and an instance of a class, object. Objects can store data using a variable
belong to the object and also can have a functionality using functions
(methods) within a class. A class contains methods such as an initializer, a
string method, and a represent method etc. The structure of this programming is
that many methods contain variables are within a class. This type of a structure
makes a complex function to be easier to read and to trace back the code the
user typed. As well as it helps to define an error easier.
I learnt writing classes in CSC108 so I was familiar with
the concept of classes and importing a class into another class except the way
of writing the function. In the first lecture, the example the professor showed
made me confused because the type contract for a function was written in the
parameter. I have never seen those kinds of examples in CSC108 course, so I was
wondered if it works or not. I tried to write a random class and methods as the
examples to see if it works and liked the shorter way to write a function. As well
as I found a new code fragment that I have never seen, which is isinstance(). I
looked up the use of isinstance(), and found out it checks if a given object is
an instance of a class. Now I am familiar with new style of writing a function
and a new code. So far I am okay with examples, but if I am confused or cannot
figure out something, I might just look up and figure out the way it works.