📜 ⬆️ ⬇️

All programmers think that C ++ supports OOP, except the OOP author.

Recently, I have noticed articles on the topic “OOP is cool vs procedural programming is bad” and “OOP is bad vs procedural programming is cool” and “OOP and procedural is bad vs future is XYZ principles”, where XYZ is a fashionable new concept.

image

The most ridiculous thing in these articles is that many by OOP understand a certain principle once laid down in C ++. And rarely anyone really understands what the OOP. Suddenly it seemed to me that 99% of programmers generally do not understand what OOP is. But maybe I'm wrong? Let's get a look…

The purpose of the article is not holivar, but an attempt to realize a different point of view on the concept of OOP. The point of view is not mine, but the author. The worst thing is that my point of view is somewhere closer to the author’s, but far from what most programmers understand by this term.

Let's break down the OOP wording


OOP = object-oriented programming. In other words, programming which is based on the creation of certain objects. And someone decided that we are talking about classes. But who decided this? When? And why?
')
From student benches, you can raise the story and find out that one of the first to implement the principles of OOP and run them to the masses is C ++.

All that went further inherited this very concept. All would be nothing, but there is one problem. Everyone thinks that C ++ is supported and associated with OOP, except for the author of the OOP concept.

Here is his quote:
I came up with the term "object-oriented", and I assure you that I did not mean C ++

- Alain Kay

Many more interesting quotes on links:

1. Interesting article on Habré here

2. A selection of 15 quotes, some of which are very interesting here.

Some of these quotes will be used further to turn the mind.

If C ++ is not the OOP that the author meant, what is that?


The author claims that we are talking about something similar to SmallTalk. And recommends that everyone learn LISP. But how many readers are familiar with these languages? If there are those who are deeply familiar with these languages ​​and experience in solving real applied problems, then I will be very happy for the comments on this article.

But my attention was caught even a number of his quotes on the topic:

1. “I regret having invented the term“ objects ”many years ago, because it forces people to concentrate on small ideas. The really big idea is messages. ”

2. "The key to making large and expanding systems is to figure out how modules will communicate with each other, rather than take care of their internal properties and behavior."

3. "I thought of objects as living cells or as separate computers on a network that exchange messages."

4. “One of the key ideas is to make systems that would continue to work during testing and, especially, when making changes. Even big changes should be incremental and spend no more than a second before it takes effect. ”

5. OOP for me are messages, local hold and protection, hiding the state and late binding of everything. This can be done in Smalltalk and in LISP.

And another series for the pressure of thought:
I'm sorry that I used the term “object” a long time ago for this topic, because of this, many people focus on the smaller of the ideas. The big idea that modern statically-typed OO languages ​​lack: The big idea is “messages”. The key to creating good scalable systems is to work out the communication mechanisms of the modules, and not to work out their internal properties and behavior.

In these quotes, I would point out the following features:

1. It is not about programming languages, but about the approach.
2. The focus is not on objects, and objects are not something that is generally accepted.
3. Objects - these are modules or system components (maybe even individual computers and servers)
4. The essence is not in the objects themselves, but in the ability of these cells to communicate between each other through messages

And here we are close to turning the essence of the concept of OOP.

OOP is an application architecture.


This is not about programming languages. And about the ability of the system to create objects and provide an effective exchange of messages between them and interaction. Also worth noting is the idea that there are no such languages ​​in principle. There are only platforms that have managed to come closer in part to this ideology.

It seemed to me that I understood the essence of this idea when I was searching for a platform flexible enough to manage large complex systems, the requirements for which were changed daily.
And I managed it.

This platform has a number of correspondences to the concept of OOP in the author’s version:

1. In this system, the components exchange messages with each other and thus allow changing the behavior of each other. One component can change the behavior of other components. (compliance with the citation number 1).

2. This platform has the whole point that modules can interact with each other. At the same time inside the module itself can be written horribly with crooked hands of a stupid junior (according to quotation No. 2). And this platform has the largest number of modules in the world relative to other platforms. Probably just for the reason that in this platform, this principle is made better than anywhere else.

3. The component in this system is really more like cells that can be added or removed in a split second. There are tens of thousands of them. From them you build a system. In addition, each such cell can exchange messages with others.

4. Moreover, each component is quite autonomous and can often be disconnected and repaired without stopping the entire system. (compliance with the citation number 4). It can be updated in seconds on the fly. Inside the system there can be more than 100 such components, each of which is updated by a separate development team.

5. The system initially contains message channels. And their bundle may be later. Anytime later when needed. Today I don’t know how late and when in which place and which component I will need to change in the future. But I understand that with a high probability I can do it. As soon as I understand what state and what behavior of which component I need to change, I can do it either very simply or relatively simply.

It seemed to me that it was this platform that came closest to the concept of OOP. Probably for this reason, this platform has captured the market. Became number 1 in the world for a number of indicators. More than 25% of sites in the world and in the Russian Federation work on this platform. This is an absolute world record. I think many have already guessed what it was about :) This is WordPress.

I think that in the world there are other platforms that have managed to implement the principles of the PLO close to how the author of the concept saw it. But judging by the market share of WP with this clearly there has been success. php is just a programming language. By itself, it does not give the PLO. OOP is formed only through the layer, which provides the necessary methods for the interaction of components (or objects in the concept of the author of the concept)

Another platform in which it seemed to me to have these features is Backbone.js. JavaScript, like php, does not provide the necessary methods for OOP, but Backbone.js already gives. And allows you to create objects and provide an effective exchange of messages between them.

Or take the recently updated microservice system that communicates via the RESTfull API & Webhooks. Each such web service is in its essence an object in the concept of OOP as the author sees it.

Summary


This is not an attempt to impose your point of view. This is an attempt to understand who and how sees this ideology. I love OOP as it is in php. I use classes. At the same time, I am not against procedural programming and I think that this is good for many tasks. I respect the approach with the REST API and webhacks. But I don’t consider every method as an absolute truth and appreciate when every tool is used for its intended purpose.

Even more, I like the WordPress hook system, which allows you to create really complex systems with hundreds of components, each of which can be added or removed at any stage of the system’s development. Thus, we managed to create very complex systems for managing business processes or aggregators with the organization of many processes and people. Very complex, difficult to find analogues on the market. And judging by the quotes of the author of the OOP concept, the WordPress hooks and filters mechanism is much closer to the original concept of OOP than what is usually written as classes in php and C ++.

Who thinks about this? Who is this understanding of the PLO close? Why? Who thinks this is nonsense? Why? Talk to me...:)

Upd. 20160811


Oops. It turns out that everything I have described here is already well known and even is on Wikipedia - proof .
And even the fact that OOP is divided into class-oriented and component-oriented programming. In other words, the PLO that they usually mean is class-oriented and this is what was invented in C ++, and the one in which the article is about is component-oriented and this is what was invented by Alain Kay.

In the article I was wrong saying that 99% of programmers do not know what OOP is. In the comments were mistaken those who decided that this idea is nonsense. Something like this.

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


All Articles