Object-oriented three main ideas: encapsulation, inheritance, polymorphism.
A long time ago, the world of software development was still a muddle, regardless of the development of any software is faced with the complexity of the problem. Then structured programming came into being.
The basic idea of structured programming is: to control the process in an orderly manner, that is, to limit the order of execution of the program to three kinds of sequence, branch and loop; The common processing is attributed to the routine (function).
Although the structure solves the complicated problem of program control flow, the program includes not only the controlling structure but also the data to be processed. As processing data increases, the complexity of the program increases. At this point, object-oriented programming comes!
"The complexity of managing content and processing data Objects separately" is the problem that, in order to get the right results, the consistency of processing and data must be maintained , which is very difficult in structured programming, and the solution to this problem is data abstraction.
Data abstraction is the combination of data and processing methods . This is the beginning of the term "object". Object-oriented programming is therefore named.
Then, from the abstract principle, when multiple identical things appear, they should be grouped together, that is, the dry principle (Don ' t Repeat yourself), which leads to the concept of class.
Proper processing based on the data type (invoking the appropriate method ) should have been a tool that the programming language should have done. This is the derivation of polymorphism.
For inheritance, most of the view is that "inheritance is a way of natural evolution along with the structure and abstraction of programs." Structure and abstraction means that the common part is extracted to generate a bottom-up approach to the parent class . (If inheritance is born like this, then the multiple inheritance of several parent classes will become mainstream initially, and the Simula language that originally introduced the inheritance only provides a single inheritance.) As that the original purpose of inheritance is actually gradual refinement )
Why is object-oriented programming generated [20160307]