Origins of OOP

The article is devoted to the topic of OOP, the origins of its creation and an explanation of why it is worth using.

The story begins with the fact that the creator of OOP, Alan Curtis Kay, received a bachelor's degree in molecular biology. He was interested in the cells of organisms, their structure and behavior. In fact, in order not to reinvent the wheel and use the best practices of nature, he created this approach to programming, OOP.

All OOP is an attempt to describe the behavior of cells between each other, hence the n principles:

  • Inheritance (cells divide, receiving a set of data from a parent). Usually the cell pattern from which they inherit is general, with no unique features, something like a stem cell that adapts or copies its closest relatives.

  • Encapsulation (the cell's organs remain inside the cell, accessible for control from the inside, the cell is limited by a membrane/capsule).

  • Polymorphism (after cell division, mutations may occur). In real life, if a cell's mutation is very different from the initial one, then the immune system begins to attack it, in which case the body begins to eat itself. Such phenomena can be adopted by building your own code, avoiding natural errors.

Despite the apparent simplicity, the devil is still in the details:

  • Studying even a children's textbook on body cells, one can come to the conclusion that this thing is so complex and multifaceted that it defies simple description. The interaction of the cell's organs, its nucleus is a whole science, special chemical compounds with data sets are used to transmit the signal. It is not easy to figure it out. Programming such cell behavior is not a simple task.

  • In addition to the cell, there are other structures that also exchange signals, magnetic fields, from small to large. Animals or atomic structures of chemical compounds could be used for comparison. Why cells were taken as an example is a question. Most likely because they are a good golden mean of the life fractal.

Since fractalism was mentioned, we can talk about it separately. Once upon a time, people, crushing ore, realized that some stones split into similar segments. By crushing the ore even smaller, the pattern repeated itself. This also applied to large blocks. Then this idea was applied to things not related to manual labor. Why not use this in relation to programming.

Fractalism:

  • OOP patterns and principles are applicable not only to classes, but also to the architecture of services, groups of services, and interactions within a team.

  • Patterns can be taken not only from textbooks; principles are reflected in the surrounding world.

  • Any programming task (in theory) already has a solution at another level of abstraction. “The Simpsons already had this episode.”

A little more theory about the origin of life, in particular complex cells (these are not my theories, by the way):

  • The first cells had only a shell. There was nothing inside. The diversity of behavior, size and chemical composition led previously similar cells to new behavior. Some of them could digest/use certain chemical elements/compounds.

  • Then the cells learned to open each other's shells and consume the insides. The shells could grow together during eating. In some of these moments, the division cycles coincided. As a result, previously only the shell structure acquired a parasite. But it turned out to be useful. It helped to cook the garbage from the main digestion process. So the cells became overgrown with organs, in fact, with other cells that got there because of their greed. Synergy. In OOP, this is similar to Dependency Injection.

  • The remaining cells, simple, without organs, could not withstand the competition.

Results:

  • The world is much more connected than it seems.

  • Everything that is needed has already been invented, you just need to find it. Moreover, these are proven patterns that will help avoid problems in the future.

  • It is reasonable to apply other sciences to programming. Your learning curve can be built on this.

This article is intended primarily to broaden horizons and provide motivation to study other sciences besides computer science.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *