About sophistry (sophisms) in discussions and about the PLOSince it is not supposed to write comments in the “read-only” mode, I will again venture to write in the sandbox.
Introduction
While reading Habr, I stumbled over one of the
comments . Rather, stumbled over a quote in this comment:
“I am sure that OOP is methodologically incorrect. She starts with building classes. It is as if mathematicians would begin with axioms. But no one really starts with axioms, everyone starts with evidence. Only when a set of suitable proofs has been found, only then is the axiom derived on this basis. Those. in mathematics you end up with the axiom.
The same is true with programming: first you have to start developing algorithms, and only at the end of this work, come to the conclusion that you are able to formulate clear and consistent interfaces. It is because of this confusion in OOP that refactoring is so popular - because of the inferiority of the paradigm, you are simply doomed to rewriting the program, at the very moment when you only thought of designing it in OOP-style. ”
(c) Alexander Stepanov, co-author of C ++, author of STL
Before turning to the essence of this note (or rather, to the analysis of Stepanov’s quoted quotation), I also want to recall a short article with a provocative announcement (“sophistry is a mathematics for rogues”), which somehow caught my eye in a glossy magazine (which in itself is already strange; it is not often possible in such magazines to pay attention to something). The electronic version is
here . Further I will refer to the terms from this article, therefore I recommend reading.
Watch hands
Let us evaluate our quote from the point of view of oratory. But beautiful! As they say, watch your hands. It starts with an unexpected and loud statement, so it immediately draws attention to itself. Next, the speaker brings the listener (reader) to the analogy between the classes of the PLO and the axioms of mathematics. This analogy serves as a basis for the final chord: “you are simply doomed ...”! Applause. A curtain. Opponents plunged.
')
To be honest, I somehow never had the idea to use OOP in such an orthodox way as Stepanov describes. OOP in my understanding - just one of many very convenient tools. The PLO (paradigm) is completely edible (even tasty) and without the “default” sauce, which necessarily contains the key idea that everything is an object. The PLO does not lose any of its charms, if you turn to it as necessary, and not exclusively within the framework of its comprehensive key idea. It seems that the concept of OOP does not at all require the widespread use of objects exclusively. It’s just a good idea to reformulate this key idea, and move from the option “everything is an object”, for example, to the option “everything can be represented as an object”. Can be presented, but not necessarily to do it! And not necessarily everything will be bad.
The foundation of a quotation is an analogy between proofs and the axioms of mathematics on the one hand, and algorithms and interfaces of objects on the other. How well is such an analogy? Looks like BEGINNING FOR THE BOTTOM?
An axiom, if I do not confuse anything, and there is some initial statement that is accepted true without evidence, and itself serves as a basis for constructing other proofs (a set of axioms only requires consistency - really, just like from interfaces; however it meant). Yes, yes, somewhere in the corner of my memory the thought is nest that many of the statements, once considered merely axioms, eventually gained their evidence. But this is no reason to say that the train of thought of mathematicians always goes from proof to axioms. Formally, axioms are for some reason included in the number of theorems, and theorems are always proved, but this is also no reason to say that an axiom is always derived on the basis of suitable proofs. Looks like a FALSE SYLLOGISM?
Also in the quotation, the course of development from interfaces to algorithms is taken as absurd (supposedly, there must first be algorithms, and only then - the formulation of consistent interfaces). I do not understand why. If I suddenly found it necessary (convenient) to use an object somewhere, then I start with sketches of its structure and interface (that is, methods through which it will be possible to exchange data with this object). In fact, here I simply create some additional level of abstraction. I still don’t go into the implementation details (algorithms) at this stage, and this, in my opinion, doesn’t stop me from coming up with a consistent interface. In procedural programming, when we write a part of the code as a procedure or function, we can also begin with the interface (insert a blank function into the code, an empty function), and only then deal with the details of its implementation. And it does not look absurd. Of course, the development course is quite possible in the opposite direction: we first develop an implementation algorithm (or several at once), and then design it as a function or as a method of the class being created. But this does not mean that you always have to do this. Therefore, it seems to me that this part of the quotation also looks like a LEAST OF THE BASIS.
Of course, I admit the idea that when developing really large and complex projects, things can be exactly as Stepanov describes. My experience does not allow to judge this, therefore, I leave this aspect to your judgments. However, in any case, this is also no reason, in principle, to consider the OOP methodologically incorrect, since there are a large number of situations that the OOP methodology relies on quite well.
In the end, the key declared idea of the OOP - everything is an object - also looks like the slumbering of the choice. Well, why is “everything is an object”? Why not "everything can be represented as an object"? Or is it a translation error?
Conclusion
We often use this very math for rogues quite intuitively, just as a stereotype (pattern!) Of communication. It may be worth it to describe it in the Habré rules and prohibit the use of comments?
Shl. And forgive me if I am at work somewhere with programming theory or math. I would be happy to amend.
The purpose of this post in no way was to belittle the authority of Alexander Stepanov or someone else, and certainly not to show "how clever I am." I just wanted to draw attention to the fact that we, learning to defend our opinions in discussions, often come to the use of sophisms, and we do not even realize this. It turns out such a mathematics for crooks.
