📜 ⬆️ ⬇️

All that surrounds us - objects

I encountered object-oriented programming in 1993, when I switched from regular Pascal to the Object version. Later I worked with C ++, Java, php, JavaScript of which only in Java was immediately clearly understood “there are only objects and no steps aside”.


Usually, work begins not with a long study of the theory, but from understanding the problem to finding ways to solve it. Therefore, php was used to create sites on the server side, and javascript was used to perform certain functionality on the client side.
For other tasks, respectively, other languages. The fact that in javascript "everything - objects" I did not immediately understand. Yes, it was such a thing.
And before that, I was always tormented by questions like “how to use one common code or data, only expanding the functionality?”, “And what if a function with that name already exists?”.
Later, when I changed jobs and came in for interviews, I was asked questions about "polymorphism" and "encapsulation."
These terms were dry and did not contain a deep practical meaning.
In object-oriented programming (OOP), for me, it made sense to:


As soon as I found out that using OOP is possible in php and javascript, I began to use it.
')
I see only two drawbacks in OOP: it is necessary to think carefully about the structure of objects (be able to design) and the resources of computers are more costly.
Yes, knowledge is still needed, and there is almost never time to upgrade them. However, this is more of a joke than a serious obstacle.
I listed the disadvantages in case they were. But then, without the drawbacks, the picture will not be objective.

Plus much more:
  1. a clear map of the project (yes, it just is! - “cities” -objects within the “country” of the project) - reducing the complexity of understanding “how it works”
  2. reusability of ready-made "cubes"
  3. a quicker and clearer understanding of one’s own (after years) and alien (OOP) code, its maintenance.
  4. Protection of internal algorithms and data from involuntary changes - “black boxes”

These were the four main ones that ultimately: shorten the development and support of the project, unload the brain from "non-core noise" and push the boundaries when the project turns into a "mess".

Recently on Habré I began to meet more often articles written in style "procedural vs OOP".
Perhaps this is a real problem (OOP - for / against) for people, since such topics arise. But personally, if possible, I choose OOP.
It's more convenient and easier for me to work. It is only important to understand that OOP is only a tool.
And to use the tool must always be a qualification of a certain level.

By the way, Hanspeter Moessenboeck in 1993 already reviewed the pros and cons in his article “Costs and Benefits of OOP” .

Source: https://habr.com/ru/post/150107/


All Articles