Encapsulation, Inheritance, Polymorphism (PHP Basics - Lesson from the course). Object Oriented Programming Concepts JAVA The essence of the concept of polymorphism is that

Polymorphism is one of the three main OOP paradigms. In short, polymorphism is the ability of an object to use methods of a derived class that does not exist at the time the base one is created. For those who are not particularly knowledgeable in OOP, this probably sounds complicated. Therefore, let's look at the use of polymorphism using an example.

Statement of the problem

Let's assume that the site needs three types of publications - news, announcements and articles. They are similar in some ways - they all have a title and text, news and announcements have a date. In some ways they are different - articles have authors, news has sources, and announcements have a date after which it becomes irrelevant.

The simplest options that come to mind are to write three separate classes and work with them. Or write one class that will contain all the properties inherent in all three types of publications, and only the necessary ones will be used. But for different types Logically similar methods should work differently. Making several methods of the same type for different types (get_news, get_announcements, get_articles) is completely ignorant. This is where polymorphism comes in handy.

Abstract class

Roughly speaking, this is a template class. It implements functionality only at the level at which it is known in the at the moment. Derived classes complement it. But, it's time to move from theory to practice. Let me make a reservation right away: we are considering a primitive example with minimal functionality. All explanations are in the comments in the code.

abstract class Publication
{
// table that stores data on the element
protected $table ;

// element properties are unknown to us
protected $properties = array();

// constructor

{
// note that we don't know which table we need to get the data from
$result = mysql_query ("SELECT * FROM `" . $this -> table . "` WHERE `id`="" . $id . "" LIMIT 1" );
// we don’t know what data we received either
$this -> properties = mysql_fetch_assoc ($result);
}

// method, the same for any type of publication, returns the property value
public function get_property ($name)
{
if (isset($this -> properties [ $name ]))
return $this -> properties [ $name ];

Return false ;
}

// method, the same for any type of publication, sets the property value
public function set_property ($name, $value)
{
if (!isset($this -> properties [ $name ]))
return false ;

$this -> properties [ $name ] = $value ;

Return $value ;
}

// and this method should print the publication, but we don’t know how exactly to do this, and therefore we declare it abstract
abstract public function do_print();
}

Derived classes

Now you can move on to creating derived classes that implement the missing functionality.

class News extends Publication
{
// constructor of the news class, derived from the publications class
public function __construct ($id)
{
// set the value of the table in which news data is stored
$this -> table = "news_table" ;
parent :: __construct ($id );
}

Public function do_print()
{
echo $this -> properties ["title" ];
echo "

" ;
echo $this -> properties ["text" ];
echo "
Source: " . $this -> properties [ "source" ];
}
}

Class Announcement extends Publication
{
// constructor of the ad class derived from the publication class
public function __construct ($id)
{
// set the value of the table in which ad data is stored
$this -> table = "announcements_table" ;
// call the constructor of the parent class
parent :: __construct ($id );
}

// override the abstract print method
public function do_print()
{
echo $this -> properties ["title" ];
echo "
Attention! The announcement is valid until "
. $this -> properties ["end_date" ];
echo "

" . $this -> properties [ "text" ];
}
}

Class Article extends Publication
{
// constructor of the article class, derived from the publication class
public function __construct ($id)
{
// set the value of the table in which data on articles is stored
$this -> table = "articles_table" ;
// call the constructor of the parent class
parent :: __construct ($id );
}

// override the abstract print method
public function do_print()
{
echo $this -> properties ["title" ];
echo "

" ;
echo $this -> properties ["text" ];
echo "
" . $this -> properties [ "author" ];
}
}

Now about use

The point is that the same code is used for objects of different classes.

// fill the publication array with objects derived from Publication
$publications = new News ($news_id);
$publications = new Announcement($announcement_id);
$publications = new Article($article_id);

Foreach ($publications as $publication) (
// if we work with Publication heirs
if ($publication instanceof Publication) (
// then print the data
$publication -> do_print();
) else (
// exception or error handling
}
}

That's all. With a slight movement of the hand, the trousers turn into elegant shorts :-).

The main benefit of polymorphism is the ease with which you can create new classes that “behave” similarly to related ones, which, in turn, allows you to achieve extensibility and modifiability. The article shows only a primitive example, but even it shows how the use of abstractions can make development easier. We can work with news just like we do with advertisements or articles, and we don't even have to know what we're working with! In real, much more complex applications, this benefit is even greater.

A little theory

  • Methods that require overriding are called abstract. It is logical that if a class contains at least one abstract method, then it is also abstract.
  • Obviously, an object of an abstract class cannot be created, otherwise it would not be abstract.
  • A derived class has properties and methods that belong to the base class, and can also have its own methods and properties.
  • A method that is overridden in a derived class is called a virtual method. There is no information about this method in the base abstract class.
  • The point of abstraction is to define a method in the place where there is the most complete information about how it should work.
UPD: Regarding sql-inj and MVC violations - gentlemen, this is just an example, and an example of polymorphism, in which I do not consider it necessary to pay attention to these things. This is a topic for completely different articles.

Polymorphism (in programming languages) is the ability of objects with the same specification to have different implementations.

A programming language supports polymorphism if classes with the same specification can have different implementations - for example, the implementation of a class can be changed through the process of inheritance.

Briefly, the meaning of polymorphism can be expressed in the phrase: “One interface, many implementations.”

Polymorphism is one of the four most important mechanisms of object-oriented programming (along with abstraction, encapsulation and inheritance).

Polymorphism allows you to write more abstract programs and increase code reuse. The general properties of objects are combined into a system, which can be called differently - interface, class. Community has external and internal expression:

external commonality manifests itself as the same set of methods with the same names and signatures (name of methods and types of arguments and their number);

internal commonality - the same functionality of the methods. It can be described intuitively or expressed in the form of strict laws, rules to which methods must obey. The ability to assign different functionality to one method (function, operation) is called method overloading (function overloading, operation overloading).

Class geometric shapes(ellipse, polygon) can have methods for geometric transformations (displacement, rotation, scaling).

The stream class has methods for serial data transfer. The stream can be information entered by the user from the terminal, data exchange via computer network, file (if sequential data processing is required, for example, when parsing source codes of programs).

In object-oriented languages

In object-oriented languages, a class is an abstract data type.[Note. 1] Polymorphism is implemented using class inheritance and virtual functions. A child class inherits the signatures of the methods of the parent class, and the implementation, as a result of method overriding, of these methods can be different, corresponding to the specifics of the descendant class. Other functions may treat an object as an instance of a parent class, but if the object is actually an instance of a child class, the method overridden in the child class will be called at runtime. This is called late binding. [An example use case would be the processing of an array containing instances of both a parent and a child class: obviously, such an array can only be declared as an array of the type of the parent class and only methods of that class can be called on objects of the array, but if in If some methods have been overridden in the descendant class, then in runtime mode for instances of this class they will be called, and not the methods of the parent class.]

A child class can itself be a parent. This allows you to build complex inheritance schemes - tree-like or network-like.

Abstract (or pure virtual) methods have no implementation at all (in fact, some languages, such as C++, allow abstract methods to be implemented in a parent class). They are specifically designed for inheritance. Their implementation must be defined in descendant classes.

A class can inherit functionality from multiple classes. This is called multiple inheritance. Multiple inheritance creates a well-known problem (in C++) when a class inherits from multiple proxy classes, which in turn inherit from the same class (the so-called "Diamond Problem"): if a common ancestor method was overridden in the proxy, it is unknown which implementation of the method must be inherited by a common descendant. This problem is solved by refusing multiple inheritance for classes and allowing multiple inheritance for completely abstract classes (that is, interfaces) (C#, Delphi, Java), or through virtual inheritance (C++).

In functional languages

Polymorphism in functional languages ​​will be discussed using Haskell as an example.

Genetic polymorphism is a condition in which there is long-term diversity of genes, but the frequency of the rarest gene in the population is more than one percent. Its maintenance occurs due to constant mutation of genes, as well as their constant recombination. According to research conducted by scientists, genetic polymorphism has become widespread, because there can be several million gene combinations.

Large stock

The better adaptation of a population to a new environment depends on a large supply of polymorphism, and in this case evolution occurs much faster. It is not practical to estimate the entire number of polymorphic alleles using traditional genetic methods. This is due to the fact that the presence of a certain gene in the genotype is achieved by crossing individuals that have different phenotypic characteristics determined by the gene. If you know what part of a certain population consists of individuals with different phenotypes, then it becomes possible to determine the number of alleles on which the formation of a particular trait depends.

How did it all start?

Genetics began to develop rapidly in the 60s of the last century, it was then that enzymes in gels began to be used, which made it possible to determine genetic polymorphism. What is this method? It is with its help that proteins move in an electric field, which depends on the size of the protein being moved, its configuration, as well as the total charge in different parts of the gel. After this, depending on the location and number of spots that appear, the identified substance is identified. To assess protein polymorphism in a population, it is worth examining approximately 20 or more loci. Then, using a mathematical method, the number and ratio of homo- and heterozygotes are determined. According to research, some genes can be monomorphic, while others can be unusually polymorphic.

Types of polymorphism

The concept of polymorphism is extremely broad; it includes a transitional and a balanced variant. This depends on the selective value of the gene and natural selection, which puts pressure on the population. In addition, it can be genetic and chromosomal.

Gene and chromosomal polymorphism

Gene polymorphism is represented in the body by more than one allele; a striking example of this is blood. Chromosomal represents differences within chromosomes that occur due to aberrations. At the same time, there are differences in heterochromatic regions. In the absence of pathology that will lead to impairment or death, such mutations are neutral.

Transitional polymorphism

Transitional polymorphism occurs when an allele that was once common is replaced in a population by another that provides its carrier with greater adaptability (also called multiple allelism). With a given variety, there is a directional shift in the percentage of genotypes, due to which evolution occurs and its dynamics occur. The phenomenon of the industrial mechanism may become good example, which characterizes transitional polymorphism. What it is is shown by a simple butterfly, which, with the development of industry, replaced white their wings on the dark. This phenomenon began to be observed in England, where more than 80 species of butterflies turned from pale cream flowers to dark ones, which was first noticed after 1848 in Manchester due to the rapid development of industry. Already in 1895, more than 95% of moths acquired a dark coloration of their wings. Such changes are associated with the fact that tree trunks have become more smoky, and light-colored butterflies have become easy prey for thrushes and robins. The changes occurred due to mutant melanistic alleles.

Balanced polymorphism

The definition of “balanced polymorphism” characterizes the absence of a shift in any numerical ratios of various forms of genotypes in a population that is in stable environmental conditions. This means that from generation to generation the ratio remains the same, but may fluctuate slightly within a certain value, which is constant. In comparison with transitional, balanced polymorphism - what is it? It is primarily a static evolutionary process. I. I. Shmalhausen in 1940 also gave it the name equilibrium heteromorphism.

Example of balanced polymorphism

A clear example of balanced polymorphism is the presence of two sexes in many monogamous animals. This is due to the fact that they have equal selective advantages. Their ratio within one population is always equal. If there is polygamy in a population, the selective ratio of representatives of both sexes can be disrupted, in which case representatives of one sex can either be completely destroyed or are eliminated from reproduction to a greater extent than representatives of the opposite sex.

Another example would be the blood group according to the ABO system. In this case, the frequency of different genotypes in different populations may be different, but at the same time it does not change its constancy from generation to generation. Simply put, no one genotype has a selective advantage over another. According to statistics, men with the first blood group have a longer life expectancy than the rest of the stronger sex with other blood groups. Along with this, the risk of developing duodenal ulcer in the presence of the first group is higher, but it can perforate, and this will cause death if assistance is delayed.

Genetic balance

This fragile state can be disrupted in a population as a consequence of the occurrence, and they must occur with a certain frequency and in each generation. Studies have shown that polymorphisms of genes of the hemostasis system, the decoding of which makes it clear whether the evolutionary process promotes these changes or, conversely, counteracts them, are extremely important. If you trace the course of the mutant process in a particular population, you can also judge its value for adaptation. It can be equal to one if the mutation is not excluded during the selection process and there are no obstacles to its spread.

Most cases show that the value of such genes is less than one, and in the case of the inability of such mutants to reproduce, everything comes down to 0. Mutations of this kind are swept aside in the process of natural selection, but this does not exclude repeated changes in the same gene, which compensates for elimination which is carried out by selection. Then equilibrium is reached, mutated genes can appear or, conversely, disappear. This leads to a balanced process.

An example that can clearly characterize what is happening is sickle cell anemia. In this case, a dominant mutated gene in a homozygous state contributes to the early death of the organism. Heterozygous organisms survive but are more susceptible to malaria disease. Balanced polymorphism of the sickle cell anemia gene can be traced in areas where this tropical disease is widespread. In such a population, homozygotes (individuals with the same genes) are eliminated, and selection acts in favor of heterozygotes (individuals with different genes). Due to the multi-vector selection occurring in the gene pool of the population, genotypes are maintained in each generation, which ensure better adaptability of the organism to environmental conditions. Along with the presence of the sickle cell anemia gene, there are other types of genes that characterize polymorphism. What does this give? The answer to this question will be a phenomenon called heterosis.

Heterozygous mutations and polymorphism

Heterozygous polymorphism provides for the absence of phenotypic changes in the presence of recessive mutations, even if they are harmful. But at the same time, they can accumulate in the population up to high level, which may exceed harmful dominant mutations.

evolutionary process

The evolutionary process is continuous, and its prerequisite is polymorphism. What this means is the constant adaptability of a particular population to its habitat. Organisms of different sexes that live within the same group can be in a heterozygous state and transmitted from generation to generation for many years. Along with this, they may not have a phenotypic manifestation - due to the huge reserve of genetic variability.

Fibrinogen gene

In most cases, researchers consider fibrinogen gene polymorphism as a precursor to the development of ischemic stroke. But at the moment, the problem in which genetic and acquired factors are able to influence the development of this disease is coming to the fore. This type of stroke develops due to thrombosis of the cerebral arteries, and by studying the polymorphism of the fibrinogen gene, one can understand many processes, by influencing which the disease can be prevented. At present, scientists have not sufficiently studied the connections between genetic changes and biochemical blood parameters. Further research will make it possible to influence the course of the disease, change its course, or simply prevent it at an early stage of development.

Programming is the process of developing solutions to “live”, dynamic problems in the form of rigid structures of code, data, functions and algorithms. The procedure for forming strict syntax from vague semantics. Real-life problems are a well-known big algorithmization problem: to achieve the right solution, the problem must be placed in precise syntactic structures.

OOP has twice attempted to "break" this ancient programming concept, but the "shackles" of the classical style of data coding and algorithms are still strong.

Level and qualifications

Computer science began with calculations, but the speed with which the acceleration of movement into the field of information processing is increasing is not yet fast enough for classical programming to become impossible and cease to exist.

It is also objective that the developer does not insist, and the customer does not demand a real solution to real problems. Both sides are accustomed to being limited by available tools and familiar capabilities.

Forms of OOP polymorphism, ideas of code encapsulation and inheritance of properties (methods) lie in the sphere of programming, but not in the sphere of the problem being solved.

A case in point is the PHPOffice/PHPWord library. To use it you need a developer qualification, you need to create own system objects, but the current level of the customer (customer requirements) is a trivial composition that the programmer covers with his development (otherwise the requirements cannot be satisfied). The situation is something like this:

In this case, the use of a library is the task of document formatting, for example, a diploma or dissertation must be formatted according to the standard. The customer presented his demands, and the programmer went his own way much further.

A complete parsing of the document was performed, its assembly in the required format, work with tables of any nesting level, merging and splitting cells, printing in any direction, etc.

Polymorphism and OOP

I can’t think of a better definition for polymorphism than to refer to the history of the development of the idea of ​​object-oriented programming, so popular today, so often used, but unrealized in essence still is.

  • encapsulation;
  • polymorphism;
  • inheritance.

Some also add: abstraction, and most often it is this, and really the main point, that is used as the foundation for describing the essence of OOP.

So, opinions about OOP are polymorphic: they describe one thing, are designed differently, or, conversely, they describe different things, but are based on four identical positions.

Democratic principles are not typical for the region information technology, but we should give it its due: the combination and coexistence of many opinions about the same thing is real polymorphism in action.

Popular definitions of polymorphism

OOP is the next stage in the development of information technology. Few people argue with this, but its main axioms and provisions differ so much in terms of semantics that they do not deserve attention outside of their totality.

  1. Polymorphism in programming is the ability to provide the same interface for different underlying forms (data types).
  2. Polymorphism is the ability of objects to have different implementations.
  3. Polymorphism is the ability of a function...
  4. Classic (from the creator of C/C++): “one interface - many implementations.”
  5. Parametric polymorphism means...
  6. Polymorphism is a provision of type theory...
  7. Abstraction is impossible without encapsulation and inheritance, just as polymorphism is impossible without inheritance...

We can agree that all this refers to the same thing: but the form of expression of thought, essence and content are not similar. But there is still something in common.

Entity: developer - customer

Classical software development presupposes the presence of a programmer and a task (client, customer). A programmer examines a problem, formalizes it, and makes code that leads to a solution. The customer denies everything proposed or only part of it, pointing out shortcomings, and the programmer does his job again.

This cycle of the problem solving process suggests that two completely different entities are clearly combined here:

  • the computer cannot solve the problem itself;
  • a program is needed so that the computer can “understand” and “solve” the problem.

The task is the sphere of competence of the customer, the program is an algorithm for “adapting” the task to the capabilities of the computer - the sphere of competence of the programmer. The role of the latter is to “adapt” the computer to the requirements of the task, and this is unnecessary!

Offers abstract. There are objects - this is the customer’s sphere; there is the implementation of objects - this is the sphere of the programmer. There is no “technological” connection between the customer and the developer. The idea is radical, not implemented to this day, but something is already working stably.

Windows, buttons and other objects

The history of the Air Art Technology, Object Magazine, Turbo Vision, Graph Vision is already history. Few people remember these implementations of OOP, they are practically not used and forgotten, but the Windows window interface is familiar to millions of users, and objects in PHP, JavaScript and other Internet technology languages ​​are used by hundreds of thousands of code developers, and millions of visitors to web resources know about them.

This is probably the only correct way in which OOP should have developed: encapsulation, inheritance, polymorphism for the developer, but not for the user. It is characteristic that this position was the main one when developing the visual design (interface) software Windows application programs such as Turbo Vision and Graph Vision.

The concept behind products like the Air Art Technology and Object Magazine was significantly different. Here the abstract object was the very first ancestor information structure, encapsulated information processing code at an abstract level. The objects of windows, buttons, and visual design elements were secondary here.

In the first version (Windows & etc.), the OOP paradigm: encapsulation, inheritance, polymorphism was designated at the level of an abstract ancestor, and the implementation of the code was formed at the level of each specific descendant along the inheritance branch according to the required structure and content.

In the second option (the Air Art Technology and Object Magazine), the level of the abstract object is important. What a particular descendant will have is not the point, the main thing is that its inheritance branch satisfies the requirements of all parents down to the root abstraction.

Object and system of objects: algorithm

An ideal object-oriented concept can only manipulate objects and systems of objects.

In modern programming languages, an object (class) is usually understood as a description of an object and an instance of an object, and in order to use the description of an object, languages ​​allow the programmer to work with static objects, while a dynamic object - descriptions, with its own unique content and structure, but using the same methods (properties) of description.

Current practice refers to the concept of an object as a tool, that is, a programming language, an interface, access to a database, a network connection, but there is nothing that indicates the interests of the customer, the problem being solved.

This is ideal for simple OOP: polymorphism makes it possible to make, in particular, a variety of design elements, but manage them with the same code. But here we are not talking about the objects of the problem, which is not at all considered as a subject for object-oriented analysis.

Programmers adopted OOP as a means to improve the quality and productivity of their work, but did not cede a single bit of “their territory” to the customer. The basic concepts of OOP - encapsulation, inheritance, polymorphism - remained in the development area, and were not transplanted into the task area.

Object and system of objects: problem and solution

Computer - programmer - task. The middle link is redundant. Ideally, there should be only two relatively dependent circuits: (computer - programmer) - task. That is, the user, customer or visitor has a tool to solve their problem. The customer does not care how the tool is implemented.

Ideally, this is just a computer that is able to understand what the customer wants and do what he wants. What it will look like: a local program or a website accessible through a browser, special program distributed information processing, information system for the customer - it doesn’t matter.

It is important that there is no unnecessary link between the task and the computer, but the first is understood and solved by the second. To achieve this goal, the computer and the customer must be connected by one system of objects, and the meaning, structure and content of each object are determined by the customer, and the methods and properties of the objects are implemented by the programmer.

It is ideal when the customer’s work on creating the system of objects he needs and the work on implementing the methods and properties of these objects are separated in time. The further the implementation of a system of objects (programmer) is from its semantic content (customer), the better the quality of the process.

Nothing prevents the customer and the programmer from interacting in the process of solving a problem, but a clear separation of semantics is important. Everyone should do their own thing, the programmer is not obliged to master the scope of the task, and the customer should not understand the code, and, moreover, the parties should not give each other advice on what does not concern them.

Traditional and object programming

The basic postulates of OOP: encapsulation, inheritance, polymorphism in the form in which they have become familiar and in demand, lead to a noticeable improvement in the quality and reliability of the code, significantly speed up the work of the programmer and have a lot of other positive qualities.

But things are still there: classical programming is not inferior to its position, and many object-oriented ideas are implemented in classical code.

However, the ideas of OOP and recursion led to an adequate influence on the syntax of classical syntax operators, on the logic of constructing ordinary code that has nothing to do with the object-oriented style of writing and thinking.

Lists and queues were transformed, the concept of the first and last element of an array appeared, “for each” loops appeared, and reference options for naming, using and executing became even more popular than before.

Actually, the very fact that variables have lost their “clear” face (the type of a variable can change as needed, and there is no need to describe a variable at all) says that the classics, in fact, long ago became object-oriented and recognized the basic principles of OOP: encapsulation , inheritance, polymorphism as ideas of significant importance.

What is it based on: an object or a system?

Abstraction, as the main conceptual position of OOP, regardless of where the area of ​​responsibility (implementation) of the object is located - at the level of the first abstract object or at the level of a specific descendant - leaves open the question: where to start everything, from the object or from the system?

If you put an object as a basis, then it will never become a system, since the system will be inside it, and it itself will become a rigid image of a very specific beginning. Here problems arise with abstraction: the initial object precisely captures the main thing in the problem being solved, that is, it is no longer transferable to another problem.

If we base it on a system of objects, we get a system of systems. This is difficult to imagine in relation to a specific task, and where to start development is also difficult to understand. By and large, the polymorphism of OOP with its differences in entities, forms of implementation, and the number of actual parameters in functions gives an idea of ​​the system that lies at the beginning as:

  • about options for solving a problem (for example, a menu);
  • about initial conditions (application of the problem in different conditions, data);
  • about operating modes (testing, setting, operation).

But this and similar ones do not give any grounds to base the solution of the problem on a system of objects. Often it is enough to define one single starting object.

History of the problem solving process

The most important principles of OOP: polymorphism and abstraction - prioritize the initial object as a system of objects. In a debate about which should come first, the chicken or the egg, here the chicken wins.

There is no doubt that everything must begin with an abstract object, and not with a system of objects. But if we take into account the factor of time and apply it at the level of each object, starting from the very first abstract one, then the contradictory idea of ​​putting both the object and the system at the beginning of the decision is the only reasonable one.

If the classical concept of programming, in the course of solving a problem, changes data, the contents of the database, changes files, etc., then in the OOP concept, polymorphism, encapsulation and the time factor change the content, structure and properties of the system of objects of the problem being solved.

A programmer in OOP is least interested in the concept of a file, a database, an algorithm - these are particulars, here the programmer thinks in objects, but objects exist in time and change in the course of achieving the desired.

Thus, at the beginning lies the object as a system of objects and the logic of this system - the time scale: launching a task, forming the first object, entering or collecting data, forming the next object, but nothing prevents the first object from proceeding to the next solution.

Each level of objects acts as independent system objects, that is, it is one object, but in the context of the process that has begun and the meaning of time, it is a system of objects on the time scale. For the full implementation of OOP, polymorphism, inheritance and the time factor together ensure the dynamics of the first, that is, an object can not only change over time, but also generate objects not intended by the developer, generated by the execution of a task during the process, designed by the customer.

Real OOP polymorphism, example

The complexity of problems that OOP can do is not comparable to what is available classic version writing programs. Of course, it is always possible to solve any problem in the usual way, but the question of how much it will “cost” time and effort often makes the result useless.

The PHPOffice/PHPWord library was developed not long ago, but in order to use its capabilities, you almost always have to create your own object system. For example, a simple *.docx file:

is a zip archive of many files and folders in the Office Open XML format (OpenXML, OOXML). Each file is written in XML tags, and when adding, changing and deleting letters, words, tables, lists and other elements, the contents of the files begin to represent a sequence of tags that do not always contain complete elements; often one element is written with many tags.

If you imagine this file as a sequence of tags, you get an interesting picture:

It is easy to notice that the first and only paragraph of the document is represented by many tags. As for the table and the tables built into it, the volume of description of all elements cannot be perceived, but is accessible to an object-oriented application.

In fact, in the figure, green is the test output of tags, yellow is the parameters and type of the tag, and beige is the content. The created objects are oriented to machine processing. Only the operations of opening a document file, formatting and writing it become available to a person.

The solution is simple and practical, but the implementation is more computer-oriented than human-oriented due to the volume of functionality performed and complex relationships between objects.

OOP Area State

The development of website management systems, technologies for setting up and managing servers, and experience in developing dynamic websites have made object-oriented programming accessible to everyone. The problem is how to change your thinking and get used to thinking at the level of objects, and not in the context of sequentially executed code.

Typically, the transition from classical programming to object-oriented programming takes two to three months, but the costs are more than worth it. The potential of modern programming languages, primarily PHP and JavaScript, will satisfy the most sophisticated developer.

Modern OOP - polymorphism, inheritance and the ability to form object properties - are convenient and practical, the language syntax and auxiliary tools ensure ease of use and code efficiency.

Perspectives on the object idea

It’s quite difficult to say how long classical programming will last and how OOP will develop. Apparently, tool developers do not plan to consider the context of the consumer (user, customer).

OOP tools - polymorphism, inheritance, encapsulation and abstraction - are developer-oriented.

Modern information systems and web resources strive to reflect reality, ensure the functioning of real objects and create an environment for their functioning that is so simple that it will be accessible to a consumer who is far from programming and completely immersed in his field of competence.

Polymorphism is the ability of a substance of the same composition to exist, based on external conditions, in several crystalline forms (polymorphic modifications) with different structures (for simple substances this phenomenon is sometimes called allotropy).

The phenomenon of polymorphism was first discovered by the German chemist and mineralogist E. Mitscherlich in 1821. Polymorphism is widespread in nature and is one of the characteristic properties of crystalline substances. Polymorphic modifications, differing in internal structure, therefore have different properties. Therefore, the study of polymorphism is extremely important for practice.

The external conditions that determine polymorphism include, first of all, temperature and pressure, therefore each polymorphic modification has its own range of temperatures and pressures at which it exists in a thermodynamically stable (equilibrium) state and outside of which it cannot be stable, although it can exist in metastable, i.e. non-equilibrium state.

Carbon, silicon, phosphorus, iron and other elements exist in various polymorphic modifications. The physical properties of different modifications of the same substance can differ significantly. For example, modifications of carbon that crystallize in the form of diamond (cubic system) or in the form of graphite (hexagonal system) differ sharply from each other in physical properties, despite the identity of the composition. If a polymorphic transformation is accompanied by minor changes in structure, the physical properties of the substance change insignificantly. Each specific substance must have two, three or more polymorphic modifications. Various modifications are usually designated Greek letters α, β, γ etc., with the first letters usually referring to modifications that are stable at higher temperatures.

When a high-temperature modification is transformed into a lower-temperature one, usually the original external shape of the crystals is preserved, while the internal structure of the substance undergoes changes. Such preservation external form, which does not correspond to the newly formed structure of the crystal lattice, is called paramorphosis. Paramorphoses are known in nature β -quartz (trigonal symmetry) according to α -quartz (hexagonal symmetry), calcite CaCO 3 (trigonal symmetry) over aragonite (orthorhombic symmetry), etc.

Regardless of the nature of the structural changes that occur during polymorphic transformations, two types of them are distinguished: enantiotropic (reversible) and monotropic (irreversible) transformations.

The reversible transformation of one modification into another, carried out at constant pressure and a certain transition temperature (point), at which these modifications are in a state of equilibrium, i.e. equally stable, called enantiotropic. This can be shown schematically as follows:

α ↔ β↔liquid

those. the α → β transition is enantiotropic. Examples of enantiotropic polymorphic transformations are transformations between polymorphic forms of SiO 2 ˸

Polymorphism - concept and types. Classification and features of the category "Polymorphism" 2015, 2017-2018.

  • - Polymorphism of individuals

    Human individuals, having a number of common properties, at the same time are not identical to each other in terms of species qualities. They differ from each other physically, mentally, and socially. Such differences include height, skin and hair color, appearance individual, gait,... .


  • - Disruptive favors the preservation of extreme types and the elimination of intermediate ones. Leads to the preservation and enhancement of polymorphism.

  • - Intraspecific differentiation of humanity. Races as an expression of genetic polymorphism of humanity. Species unity of humanity.

    INTRA-SPECIES DIFFERENTIATION OF HUMANITY: Since the emergence of H. sapiens, the social in man has become his essence and biological evolution has changed, manifesting itself in the emergence of wide genetic polymorphism. Genetic diversity at the level... .


  • 
    Top