After reading How to Think Like a Computer Scientist I actually understood a little more about the so-called "Object Oriented Programming" (OOP).
The things that seemed relevant about what I read are the following:
- OOP is commonly used because of its relation to real life. For us humans it is easier to have methods of classes of objects than just functions that are not part of anything and that are just lying around waiting to be applied on a certain other object where it becomes useful.
Because of my lack of creativity now, I will copy the example that helped me understand this idea better, (it comes from the link I copied above).
"In real life our cook method is part of our microwave oven — we don’t have a cook function sitting in the corner of the kitchen, into which we pass the microwave!"
"In real life our cook method is part of our microwave oven — we don’t have a cook function sitting in the corner of the kitchen, into which we pass the microwave!"
- The second thing I found useful in this link was the explanation of Methods, Classes and Objects. I feel like the article helps create a mental map of what goes on in Python, and since we already had some familiarity with all of this vocabulary, it is easy to figure out the reason to use the methods suggested over others that might cross our mind.
The best example of this, is using methods instead of functions. When you create a class you will be able to create objects with very similar characteristics and by creating methods in the class you can implement functions on the objects of the class and avoid creating variables (that you would have to create if you used a simple function that wasn't related to the class.
-The rest of the reading was also interesting but a little repetitive considering what we knew from CSC 108.
The best example of this, is using methods instead of functions. When you create a class you will be able to create objects with very similar characteristics and by creating methods in the class you can implement functions on the objects of the class and avoid creating variables (that you would have to create if you used a simple function that wasn't related to the class.
-The rest of the reading was also interesting but a little repetitive considering what we knew from CSC 108.