/ ** * title: My object-oriented program * Description: Describe me to some understanding of objects, I don't mature my mind, the article is in the update, I hope everyone will come to the discussion * Copyright: CopyRight (C) 2001 * Company: Matrixfox * @Author Motter Dear * @version This article is still updated. * /
My object-oriented program
1) Some misunderstandings for object-oriented concepts
"Object-oriented" is a vocabulary that is now called, just like last year, I like to put my company to ".com" tag. In fact, how many people can truly understand this vocabulary, it is difficult to say. I like this to compare people to the abuse of the word "object". "Object" is better than people often say "cool" and "cool", many people don't carefully consider the differences in these two words, in many cases they are general, "cool" and "cool" usually express "mood Nice ", you can be happy when you are playing, it is too cool, it's too cool." This time two vocabulary is general. But you can say "This person is cool", but you can't say "this person is very cool." The abuse of the vocabulary of "Object" occurs here, "object-oriented" and "object" are better than "cool" and "cool", which is two different concepts, but people usually mix these two vocabulary to talk about They will be expressed in "object-oriented". Common errors can be listed here:
1) There is a personal and high-spirited and you say "I don't like the scripting language of Flash 4, the Action Script of Flash 5 has a new object-oriented". "Syntax, it is very comfortable. I have been using Flash 5. Things. "(The same words also happen in the Director Lingo scripting language)
2) Visual Basic uses object-oriented properties and methods, which has greatly improved compared to past Basic languages.
3) JavaScript is an object-oriented.
and many more.
I usually listen to similar words, you must carefully examine the words of the speech and analyze what he said. It is certain that he is not really understanding what is an object-oriented thought. Many people do not distinguish between "object-oriented" and "object-based" two different concepts. Object-oriented three feature (package, inheritance, polymorphism) is not, usually "object-based" use objects, but unable to generate new object types in existing object templates, then generate new objects, that is, " Object "is based on the feature of inheritance, and" polymorphism "is a sub-object instance of the parent class, and there is no inheritance of the concept of" polymorphism ". Many popular technologies are based on objects, they use some packaged objects, call the object's approach, and set the properties of the object. But they can't let programmers derive new object types. They can only use the methods and properties of existing objects. So when you judge whether a new technology is object-oriented, it can usually use the latter two characteristics to judge. "Object-oriented" and "object" have realized the concept of "package", but object-oriented achieved "inheritance and polymorphism", and "object-based" is not implemented, which is indeed very rare.
2) Java is more thorough than C in terms of implementation of object-oriented ideas. My recent teacher said to me: "C is a target-oriented scorpion, the process of programming", this sentence I agree very much, and I have always thought about it. But after listening to him carefully, I found out that I just understood the words of the first two layers of this sentence. But there is still a layer of meaning I have not understood. You may ask, "Do C is not an object-oriented?" In fact, C is a real object-oriented programming language. But it is also a process programming language. Why do C , not only considering object-oriented features, but also more considering backward compatibility of the C language, making C hybrid languages exhibits "process" and "objects" programming double Sex. You usually continue to use the C compiler to write traditional C programs, or use C class libraries or write your own class to object-oriented programming. This "two-sided" makes people continue to retain the original C code, and also hinders the promotion of object-oriented ideas.
For a simple example, when I was 94 years, I started learning C , when I learned Turbo C , I called a class library called Turbo Vision to do project. My classmates also use Turbo C , but he has not learned C this language at all. He just uses the Turbo C compiler to recompile the program written by Turbo C, and then he proudly said to me: "Hey, I Things do with C ", it seems to say" I use C development project ", in that C is higher than PASCAL, PASCAL is more than the foxbase high-end age, the C label is definitely a very" cool "sign. I am actually very clear about his behavior. This is the first emphasis on "C is an object-oriented scorpion, the process programming", that is, the C compiler causes the compatibility of the C program to the bottom "process". It has been a long time in China, and people are done in C compiler. I was thinking, I was a person who truly understand the object than I was. I have learned C language, I know the package, inherit, and polymorphism, I learned Turbo Vision's class library, I got the Turbo Vision's class library and wrote their own class, so I know the object-oriented. In a sense, I want to be right. But from the classification of object-oriented programmers, I don't fully understand the object-oriented ideas. People engaged in object-oriented programming, can be divided into "creators" and "category of libraries", and talents that usually create class libraries are truly object to objects, they create class library supplies Those "customer programmers" are used, they start making class libraries from scratch, and they perform the entire process of object-oriented analysis, design, implementation. When you have learned C , my first feeling is that from the first creation of a class library is very troublesome, usually using the C process programming function, you must follow the newly established objects in accordance with the idea of the class, but once the class After the library is established, use the class library and derived classes, and the maintenance code is very comfortable. People who use class libraries are not all people with object-oriented ideas, usually know how to inherit and derive new objects, can use class libraries, however our thinking does not turn true, using class libraries just in form It is an object-oriented, and it is essentially an extension of the library function. This is the second heavy meaning I understand "C is a target-oriented scorpion, the process of programming", actually uses C programming people, mostly do not create classes, but use class libraries, so In order to understand the class library as an advanced library function library, it did not really understand the object-oriented thought. C 's object-oriented ideological promotion is very slow, until the MFC, OWL, VCL is coming out, and people have gradually accepted some object-oriented ideas. Why is this object-oriented road so difficult? My answer is "Because C gives us the second road to go to process programming", of course, in order to consider compatible C language, it is because of the second old road, it makes us won't consider new. Object-oriented programming way.
Until Java appeared, the object-oriented dawn was really ushered in. Is Java truly revolutionary? No, all existing Java's thoughts are inheriting from other languages and technologies, there is no revolution, and the concept of virtual machine is used in UCSD Pascal 20 years ago, but the machine speed is too slow. The performance reduction caused by virtual machine simulation is quite serious for the hardware at the time. Many things in Java itself also borrowed the C language. Even its founders also said that Java is "C -" that is, Java removes some of the uncomfortable places in C . So Java has no revolutionary things in nature, so those words to Java's praise are SUN's propaganda tricks. There is no language that will last for a long time. It's hard to say that your child will continue to use C or Java after twenty years, so we have to leave behind these floating vocabulary, find something that really needs to learn. Otherwise, all of us is Microsoft, tomorrow Sun got up, we are all sun's embarrassment. Carefully study the history of US computer technology development, Americans have always liked to sell their outdated technology like the third world, and they can always say that we will always lead your third world country for twenty years. We always learn their things behind Americans, which is indeed worrying. I said, I'm running again. Although Java has no real revolutionary things, Java is unable to actually promote object-oriented programming ideas. Using Java programming, you don't need to take into account what language to be compatible, it is a represented language. Before you master this language, you must make your programming ideas thoroughly turn to object-oriented programming, because each Java program, it is a class, you write any Java programs, you don't consciously construct an object template, no second road, can only be object-oriented programming. (I really like Java to put all kinds of class definitions and class declarations in a file, not like C , CPP and .h files are separated. Usually people who have just started learning Java are not used to, but study for a while, you will It will experience its benefits.), When using Java writing programs (I prefer --- Write class, not the program), you will have to consider the problem from an object, because your program is a Class, you must consider which things as a member variable, which as a method, to generate several classes, which variables are members variables, which are static variables and methods, and so on. Usually finished a project, you have used it to object-oriented ideas. The reason why Java is thorough than C in the object-oriented implementation because you can only use the object-oriented way to write Java programs, but C can use another non-object-oriented way to write programs. Java has no real revolutionary things, and its greatest contribution is of course to promote object-oriented ideas.
Java is generally the possibility of continuing process programming, but does not completely eliminate it. Object-oriented is a kind of thinking. It is a way to consider things, usually as a solution to us to solve the problem in process, or abstract the problem into an object to solve it. In many cases, we will do not know how to solve it according to the process, because we are usually accustomed to considering the problem of solving the problem, rather than thinking about solving the problem abstraction to resolve it. Many new technologies make us more trend to process rather than object ideas. The most obvious is the emergence of RAD (fast application development) visual technology, people can quickly develop applications by setting attributes and writing event functions, writing event functions is typical, based on process programming (at least I think so. ), How many people can distinguish between VB and Delphi, C Builder, Java's event function, and the last three use Delegation, in Java, through an Anonymous class (no name class), Or Adapter class to achieve delegation, this is an object-oriented concept, but VB is not, so the difference between the bottom layer is oblived, and when using JBuilder programming, we did not carefully study Java AWT. EVENT programming, usually, it is also written by writing it as a "class VB" of ordinary communication, and actually analyzes the code generated in the background, you can understand that these codes are real object-oriented, but If you just simply use it as a visual programming tool, you will never understand what is "entrust model", what is object-oriented programming. This is what I understand "C is the third emphasis on the object-oriented scorpion, the process programming". Whether it is C or Java, it is possible to take the procedure programming, the possibility of the process of decreasing the process, but if you do not have object-oriented programming ideas, you may still take the process of old road. (Endlessly)