When
I sit down and think about what I can write for this topic, the first thing
that jumps into my mind is this chunk of words:
"The most important advantage of the object-oriented style is that it fits the real-life experience more accurately. 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!" This helps me having a better insight of OOP.
Building a class is
like building a factory. It also has an assembling line. Firstly, __init__
method initialize object instances with default values. This is also the process when they get their attributes. After this, no matter what function we hope an object to have, we just write a method attaching to it. Finally we have to check if everything makes sense before we show the production to clients. As far as I have learned, there are two things that needs to be corrected. One is the __eq__ and the other is __repr__. These adjustments are necessary because rather than comparing two memory address, checking if the two objects are the same is more important. Similarly, the content of an object is really what the users are willing to see. Basically this is the draft of how an object instance is produced in the class factory.
I feel OOP is really close to the real life and also considerate for the users.
I feel OOP is really close to the real life and also considerate for the users.