Hello everybody! How are you? Midterms and assignments are over (for now!) and reading week, which I think has been long overdue, has just started. This week, I am not going to introduce anything new but rather, summarize the concepts we have been exposed to in the past 6 weeks!
Firstly, what is object-oriented programming? Object-oriented programming is the process of organizing data into objects and classes. Objects are anything that can store data ,and on which methods can be called. Methods are something that we can do on an object. Methods are exactly like functions except that they are defined inside classes. In my head, I like to visualize the whole process like the following:
Therefore, in some ways, object-oriented programming gives you the ability to organize a huge amount of data and call functions and methods on that data. In Python, the first method that we call is the __init__ method. It initializes every instance of the class. In other words, if we call an instance of the class, the initial values of the instance are the ones set up in the initializer. The way I like to visualize this is as the following:
Let us say we are playing a couple of board games such as Monopoly and Snake and Ladders. The initial state of the game such as how much money you are given or not, depends on the game. It is different for Monopoly, Snakes and Ladders etc. Thus, if I decide to play Monopoly(I call an instance of the game), the initial state of the game Monopoly would be called and that would be defined by the parameters in the initializer of Monopoly. On the other hand, if I decide to play Snakes and Ladders, the the initial state of the game Snakes and Ladders would be called and that would be defined by the parameters in the initializer of Snakes and Ladders.
The first parameter in many methods is the parameter "self". From what I have understood, all this parameter does is that it tells the method to work on the instance or data defined in that class.
Subclasses can be defined inside classes and they not only have the ability to inherit the methods defined in the parent classes but, to also override them. Therefore, we can define some general methods in the parent class and then either use or override them in the children classes.
Secondly, recursion is the ability to define something in terms of itself so that a huge problem can be broken down into smaller subproblems and the solution to the subproblems can be used to solve the bigger problem.
Lastly, Trees ADT are a type of Abstract Data Type in which, data is organized into nodes. The data is organized hierarchically, with the top most being the root and each root branching off into nodes and leaves. I have not fully understood Trees ADT, however,I hope to get the concept cleared in the labs and also by going to the office hours. I have realized that these two things have been really helpful in helping me understand a concept in the past.
To conclude, object-oriented programming(OOP) is a way of organizing data into objects and defining functions and methods on those objects. I hope that my summary of OOP has been accurate and helpful. I have posted a link to another student's blog, which I believe, explains OOP really well. I hope everyone has a good reading break! Stay warm! Nutella helps! http://ak148slogaddress.blogspot.fr/

No comments:
Post a Comment