понедельник, 23 февраля 2015 г.

"OOP" or "How ++ can matter"

Well, Python has OOP in it from the beginning, so let's forget the ++. Object-oriented programming is the topic of many debates, which are not the main objective of our (students) learning, so we leave those for experts and proceed with given: OOP can help (and/or allow) do things in a better, more understandable, more efficient way. People who've had some programming experience always mention OOP in a context that it is the proper, sterling way to code, which it, in many cases, indeed is. When I was working on assignment №1, I wasn't thinking how I could implement that without OOP, now that I think about it, it seems not very feasible, at least, reasonably: I'm pretty sure you can find a person who can write the same thing in ASM or in machine code, but readability and ease of use will, of course suffer. In other words, why complicate if you can simplify? Making use of "objects" which have "properties", "methods" and "attributes" - looks like a very vague idea, but you can specify each subtle aspect of the object you've created - what it looks like if you call print on it, what defines the object, how it interacts with other objects and so on. In my opinion, OOP is the further development of the idea of a variable: variables can have text and/or numbers in them, or lists of the above, can be manipulated, created, and so on. Now our "variable" (an object of type class) can itself interact using "smaller" interactions as building bricks, the "smaller" interactions being the Python itself. I'm pretty sure that I'm far from describing OOP in the best manner possible, but this is how I see it - creating building blocks that have many functions besides being a building block, just like a Swiss army knife which you tailor according to your needs.
However, there's some conventionality and formality that I don't seem to get: why would we be using a method placeholder that raises the exception when we can implement basics in it and use them later on in subclasses? Maybe it's that thing that one should remember and do, but I always try to find a reasoning, and, so far, I haven't been able to find one.

Комментариев нет:

Отправить комментарий