The following content is taken from "Design Pattern of big talk". I personally think it is good to pick out some help to help you understand it again.Idea of Object-Oriented Programming
Object-Oriented Programming
"I understand. He said to implement it in any object-oriented language, that means to implement it in an object-oriented programming method, right? OK, I learned this, but I didn't expect it at the time ."
Laruence: "All Programming beginners will have this problem, that is, they intuitively use the logic that computers can understand to describe and express the problem to be solved and the specific process of solving it. This is actually a computer-based approach. For example, the calculator program requires two numbers and operator numbers first, and then determines how to calculate the number based on the operator number, this is not wrong, but this thinking makes our program only to meet the current needs, the program is not easy to maintain, not easy to expand, not easy to reuse. This does not meet the requirements of high-quality code ."
Side dish: "I am confused, laruence. How can I make it easy to maintain, expand, and reuse? Can I be specific ?"
Movable printing, object-oriented
Laruence: "Well, I will tell you a story. You will understand ."
"In the Three Kingdoms period, Cao led millions of troops to attack Dongwu, and the army was stationed in Chibi, Yangtze River. The army and ships were connected together, And Dongwu was to be destroyed. The whole world was unified, and Cao was so happy, during the banquet, Cao had a great deal of poetry and said, 'drinking, singing, and life is amazing. ...... '. The crowd shouted: 'Good poetry! "So a Chen sub-Fast Life printing craftsman engraved printing, in order to spread the world ."
"The sample shows it to Cao. Cao feels inappropriate and says, 'drinking and singing. This is a vulgar thing. It should be better to change it to 'treat wine as change! ', So the Minister ordered the craftsman to come again. The craftsman saw the work of the overnight version in vain, and the heart was bitter. ."
"I think it is not good to show my eyes again when I look for the sample. I think it is not good to say, 'The life is really great, it is too straightforward. I should change the question to make the artistic conception. Therefore, I should change it to 'drinking wine and life? ...... 'When the minister tells the craftsman, the craftsman fainted ......!"
"You said, what is the problem here ?" Asked laruence.
The dish said: "Is it because the Three Kingdoms live printing has not yet been invented, so to change the word, it is necessary to all the stereotypes have to be re-engraved ."
Laruence: "That's good! If it is printed with movable words, you only need to change the four words, and the rest of the work is not done in white. ."
"First, to change, you only need to change the word, which can be maintained. Second, these words are not useless this time and can be reused in later printing, this is reusable. Third, if you want to add a word to this poem, you only need to add another lettering. Fourth, the arrangement of words may be vertical or horizontal, in this case, you only need to move the text to meet the arrangement requirements, which is flexible."
"Before the advent of the live-style printing technology, all the above four features could not be met. to modify them, they must be re-engraved. To add words, they must be re-engraved. to re-arrange them, they must be re-engraved, after printing this book, this version has no value for reuse."
Side dish: "Yes, when I was a child, I have been wondering why gunpowder, compass, and papermaking are all great inventions from the ground up, from the unknown to the discoveries, the movable printing is only a technological progress from the engraving printing to the movable printing. Why is it not the evaluation of printing as one of the four great inventions? This was the reason why the printing was successful ."
Benefits of object-oriented
Laruence: "ha, do you understand this? I didn't understand it before, but after several years of software development, too many customers like Cao had to change their needs and change their original ideas to gradually understand the truth. In fact, objectively speaking, the customer's requirements are not too much. Isn't it just a few words? But in the face of the completed program code, it is the embarrassment that needs to be almost repeated, which is really painful. To put it bluntly, the reason is that the program we originally wrote is not easy to maintain, has poor flexibility, and is not easy to expand, not to mention reuse. Therefore, in the face of demand changes, we need to work overtime, the helplessness of large-scale procedural procedures has become very normal. After that, when I learned the object-oriented analysis and design programming ideas, I began to consider reducing the coupling of programs through encapsulation, inheritance, and polymorphism, the problem with traditional printing is that all words are engraved on the same layout, resulting in a high coupling degree. The design pattern is used to make the program more flexible, easy to modify, and easy to reuse. I realized the benefits of object orientation. It should be like the first time a Chinese drunkard drank Moutai and the first time a western drunkard drank XO. What a cool word can I describe ."
"Yes, yes, you are right. The Four Great Inventions in ancient China should be technological advances, great creations or discoveries. The only thing that can be done is the success of thinking,Object-oriented."
I believe this article will give you a better understanding.Object-Oriented Programming.