Preface: The purpose of organizing this information is to help friends can more intuitively understand the object-oriented programming. Let later people can take some detours. However, there is a lot of vulnerabilities and mistakes, but also ask the seniors to make valuable changes, after all, exchange will make us constantly progress.
The technology is a sun-changing, he will not wait for your growth. Technologies should take out to exchange in others, they learn to understand their own subjective consciousness, there is a wrong mistake! Communication will make progress faster. I think if the computer's architecture does not have a revolutionary change, the program language we applied now is not too depreciated! What is the programming? thought! Proficient in a programming language (preferably object-oriented language), then go to other programming languages, you will find that the process is such a row of clouds! why? You have already mastered the idea of programming, then learn other, nothing more than learning a new syntax format.
I am not here to discuss how to use C or Java, nor and how to learn how you discussed them, I want to discuss with you how to understand the object-oriented. It will mainly involve "class, object, inheritance, attribute, method, static, overload, hidden, refactoring, statement, definition, initialization, assignment, etc." I will only pass by, let you have one What is the meaning of this tour means that I have achieved the purpose, and more detailed technology inside, please refer to other related books and go deep into the study! Because I just discuss how to better understand the object!
How to improve efficiency? Repeat the resources and use others to use. This is a very good idea! For you, the biggest resource is confidence and enthusiasm! Ok, let's make a spirit, let us go to the object-oriented programming!
Note: All programs in the article I use Java, of course, in C , it is very small, and I will point out in different places!
Note: The text of the text in the article uses black, indicating that the text is blue, emphasizing the text with orange, and the text is used to use red!
text:
1. basic concepts:
1.1 Preliminary prices of classes and objects
I want to say that whether it is a process-oriented language, it is also an object-oriented language, I should first give him a class and object! -------- "What is the composition of this world?" This question will give different answers if the different people will answer. If it is a chemist, he may tell you "Is it still useful? This world is a chemical substance of molecules, atoms, ions, and the like." If is a painter? He may tell you, "This world is composed of different colors." ... huh, huh, everyone is rumored! But if you let a classified person to consider the problem, it is more interesting, he will tell you that "this world is made by different types and things" good! " As an object-oriented programmer, we have to stand at the perspective of a classified perspective! Yes, this world is made of animals, plants, etc. Animals are divided into single cell animals, multi-cell animals, mammals, etc., mammals are divided into people, elephants, tigers ... I will go down!
Now, stand in an abstract angle, we give "classes" next definition! I mean, standing in an abstract angle, you answer me "What is human?" Let us look at some of the features of human beings, including attributes (some parameters, values) and methods (some behavior, he What can you do!). Everyone has some attributes such as height, weight, age, blood type, etc. People will work, people will walk upright, people will use their own mind to create tools! People can distinguish other types of animals because everyone has the properties and methods of the population. "Human" is just an abstract concept, it is just a concept, it is an entity that does not exist! But all the objects and methods of "human" group are called people! This object "people" are actual entities! Everyone is an object of this group. Why is the tiger not? Because it does not have the properties and methods of this group, the tiger will not walk upright, will not use tools, etc.! So tell the tiger is not a person! This shows that ------ class describes a set of objects with the same characteristic (attribute) and the same behavior (method). In the program, the class is actually the data type! For example: integer, decimal, etc. Integral also has a set of features and behaviors. The difference between the language-oriented language and the surface object is that the process-oriented language does not allow programmers to define data types themselves, and can only use the built-in data types in the program! In order to simulate the real world, in order to better solve the problem, we often need to create the data type necessary to solve the problem! Object-oriented programming provides us with solutions.