This
week, I’m going to be talking about Object Oriented Programming, something that
has been constantly presented to students as an extremely important topic, and I am
going to be sharing my thoughts on it.
Object-oriented
programming is programming that utilizes the knowledge of classes, objects and
methods, and allows us to create a unique class that can be modified to suit
our requirements. The new class inherits all of the methods of the default
‘object’ class, and it is also possible to inherit the methods of other types
of classes. For example, we can create a class that can record a list of books
that a person has read, and then create methods to sort the titles, authors,
publishers and more. By using object-oriented programming, we are able to deal
with many different requirements that we encounter while programming and
develop specific classes to tackle them. I believe that the greatest asset of
OOP is that it allows programmers to be flexible with their data and their
program requirements.
Personally, object-oriented programming was never too difficult for me; however, prior to this week, I did
struggle to understand the concept of the ‘self’ variable used in defining
methods for a class. When creating a class that utilized variables created in
the __init__ method, I had to use trial and error with any variable I wanted to
use in any later methods. For example, I didn’t know for sure when to put self
before a variables name to save it. This was partly due to the fact that it had
been a while since I attempted OOP, but even in CSC108 I found it a little
tricky to create methods that shared variables. However, this week I was able
to finally learn that ‘self’ is just a reference to the 'current instance of an object', and how to utilize variables created in the initializer, in other methods. Working on programs during the labs refreshed my
memory, and having to discuss the work with my lab partner also helped me to
get a better understanding of the details behind OOP.
To summarize, during week three I was able to understand
OOP better than I did before, and since it is so important, it will
definitely be used in many future programs that I will write.
Good job understanding the use of self. In your next post talk more about the important concepts.
ReplyDeleteThanks for reading, I'll be sure to do that.
ReplyDelete